diff options
author | Mark Kopenga <mkopenga@gmail.com> | 2021-08-23 10:15:38 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-23 10:15:38 +0200 |
commit | 487ad196a7c03d8cb3e0abc41dea42dd96db8a62 (patch) | |
tree | 589f36ab1814b4242e44d47fa398132bb958ad89 /pkg/commands/files.go | |
parent | 508af269fbc255162d8a01c9788dae9445db0393 (diff) | |
parent | 44140adb921d7891778deb7f1aa2f813622302f4 (diff) |
Merge pull request #1413 from Ryooooooga/feature/edit-line
Make os.editCommand customizable using template
Diffstat (limited to 'pkg/commands/files.go')
-rw-r--r-- | pkg/commands/files.go | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/pkg/commands/files.go b/pkg/commands/files.go index 9fa5fb1bd..ac508941b 100644 --- a/pkg/commands/files.go +++ b/pkg/commands/files.go @@ -4,6 +4,7 @@ import ( "fmt" "os" "path/filepath" + "strconv" "time" "github.com/go-errors/errors" @@ -321,7 +322,7 @@ func (c *GitCommand) ResetAndClean() error { return c.RemoveUntrackedFiles() } -func (c *GitCommand) EditFileCmdStr(filename string) (string, error) { +func (c *GitCommand) EditFileCmdStr(filename string, lineNumber int) (string, error) { editor := c.Config.GetUserConfig().OS.EditCommand if editor == "" { @@ -346,5 +347,12 @@ func (c *GitCommand) EditFileCmdStr(filename string) (string, error) { return "", errors.New("No editor defined in config file, $GIT_EDITOR, $VISUAL, $EDITOR, or git config") } - return fmt.Sprintf("%s %s", editor, c.OSCommand.Quote(filename)), nil + templateValues := map[string]string{ + "editor": editor, + "filename": c.OSCommand.Quote(filename), + "line": strconv.Itoa(lineNumber), + } + + editCmdTemplate := c.Config.GetUserConfig().OS.EditCommandTemplate + return utils.ResolvePlaceholderString(editCmdTemplate, templateValues), nil } |