summaryrefslogtreecommitdiffstats
path: root/pkg/commands/files.go
diff options
context:
space:
mode:
authorRyooooooga <eial5q265e5@gmail.com>2021-08-03 21:38:03 +0900
committerRyooooooga <eial5q265e5@gmail.com>2021-08-03 21:42:14 +0900
commit4f66093335e5a0d370cf43b3fc637c0795376334 (patch)
tree0f71e0ee748ff19133f5545492a4ddeb7f5f35b7 /pkg/commands/files.go
parentd626bcac0029267d3f45223198902f5cb78d9dc1 (diff)
introduce edit command template to open a specifig line of a file
Diffstat (limited to 'pkg/commands/files.go')
-rw-r--r--pkg/commands/files.go14
1 files changed, 11 insertions, 3 deletions
diff --git a/pkg/commands/files.go b/pkg/commands/files.go
index f4588aac5..1d4ad5fe6 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,8 +322,8 @@ func (c *GitCommand) ResetAndClean() error {
return c.RemoveUntrackedFiles()
}
-func (c *GitCommand) EditFileCmdStr(filename string) (string, error) {
- editor := c.Config.GetUserConfig().OS.EditCommand
+func (c *GitCommand) EditFileCmdStr(filename string, lineNumber int) (string, error) {
+ editor := c.Config.GetUserConfig().OS.Editor
if editor == "" {
editor = c.GetConfigValue("core.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),
+ }
+
+ editTemplate := c.Config.GetUserConfig().OS.EditCommand
+ return utils.ResolvePlaceholderString(editTemplate, templateValues), nil
}