1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-01-10 04:07:18 +02:00

Support multibyte characters in pane

This commit is contained in:
Ryooooooga 2021-03-02 12:51:36 +09:00 committed by Jesse Duffield
parent 9ed3a8ee05
commit a48cc245e7

View File

@ -14,7 +14,7 @@ func (c *GitCommand) GetFilesInDiff(from string, to string, reverse bool, patchM
reverseFlag = " -R " reverseFlag = " -R "
} }
filenames, err := c.OSCommand.RunCommandWithOutput("git diff --submodule --no-ext-diff --name-status %s %s %s", reverseFlag, from, to) filenames, err := c.OSCommand.RunCommandWithOutput("git diff --submodule --no-ext-diff --name-status -z %s %s %s", reverseFlag, from, to)
if err != nil { if err != nil {
return nil, err return nil, err
} }
@ -26,13 +26,12 @@ func (c *GitCommand) GetFilesInDiff(from string, to string, reverse bool, patchM
func (c *GitCommand) getCommitFilesFromFilenames(filenames string, parent string, patchManager *patch.PatchManager) []*models.CommitFile { func (c *GitCommand) getCommitFilesFromFilenames(filenames string, parent string, patchManager *patch.PatchManager) []*models.CommitFile {
commitFiles := make([]*models.CommitFile, 0) commitFiles := make([]*models.CommitFile, 0)
for _, line := range strings.Split(strings.TrimRight(filenames, "\n"), "\n") { lines := strings.Split(strings.TrimRight(filenames, "\x00"), "\x00")
n := len(lines)
for i := 0; i < n-1; i += 2 {
// typical result looks like 'A my_file' meaning my_file was added // typical result looks like 'A my_file' meaning my_file was added
if line == "" { changeStatus := lines[i+0]
continue name := lines[i+1]
}
changeStatus := line[0:1]
name := line[2:]
status := patch.UNSELECTED status := patch.UNSELECTED
if patchManager != nil && patchManager.To == parent { if patchManager != nil && patchManager.To == parent {
status = patchManager.GetFileStatus(name) status = patchManager.GetFileStatus(name)