From a48cc245e711f144254b2bb13efe901cdfbd9059 Mon Sep 17 00:00:00 2001 From: Ryooooooga Date: Tue, 2 Mar 2021 12:51:36 +0900 Subject: [PATCH] Support multibyte characters in pane --- pkg/commands/loading_commit_files.go | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/pkg/commands/loading_commit_files.go b/pkg/commands/loading_commit_files.go index 8a633156c..ad209fdd3 100644 --- a/pkg/commands/loading_commit_files.go +++ b/pkg/commands/loading_commit_files.go @@ -14,7 +14,7 @@ func (c *GitCommand) GetFilesInDiff(from string, to string, reverse bool, patchM 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 { 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 { 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 - if line == "" { - continue - } - changeStatus := line[0:1] - name := line[2:] + changeStatus := lines[i+0] + name := lines[i+1] status := patch.UNSELECTED if patchManager != nil && patchManager.To == parent { status = patchManager.GetFileStatus(name)