summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Duffield <jessedduffield@gmail.com>2022-02-06 13:42:17 +1100
committerJesse Duffield <jessedduffield@gmail.com>2022-03-17 19:13:40 +1100
commitcd31a762b97c071fbd33ea9b82f679890e68eaa7 (patch)
tree7533f1bd20578fa81a8f8cea8772a2397dc0864a
parentd82f175e79f18756769d91de94458b095130297c (diff)
rename OSCommand field to os
-rw-r--r--pkg/commands/oscommands/os.go5
-rw-r--r--pkg/gui/branches_panel.go2
-rw-r--r--pkg/gui/controllers/files_helper.go7
-rw-r--r--pkg/gui/custom_commands.go4
-rw-r--r--pkg/gui/diffing.go2
-rw-r--r--pkg/gui/global_handlers.go2
-rw-r--r--pkg/gui/gpg.go4
-rw-r--r--pkg/gui/gui.go14
-rw-r--r--pkg/gui/information_panel.go4
-rw-r--r--pkg/gui/line_by_line_panel.go4
-rw-r--r--pkg/gui/pull_request_menu_panel.go2
-rw-r--r--pkg/gui/quitting.go2
-rw-r--r--pkg/gui/recent_repos_panel.go2
13 files changed, 32 insertions, 22 deletions
diff --git a/pkg/commands/oscommands/os.go b/pkg/commands/oscommands/os.go
index 53f5bd6f6..1c4f5bf28 100644
--- a/pkg/commands/oscommands/os.go
+++ b/pkg/commands/oscommands/os.go
@@ -72,9 +72,14 @@ func FileType(path string) string {
}
func (c *OSCommand) OpenFile(filename string) error {
+ return c.OpenFileAtLine(filename, 1)
+}
+
+func (c *OSCommand) OpenFileAtLine(filename string, lineNumber int) error {
commandTemplate := c.UserConfig.OS.OpenCommand
templateValues := map[string]string{
"filename": c.Quote(filename),
+ "line": fmt.Sprintf("%d", lineNumber),
}
command := utils.ResolvePlaceholderString(commandTemplate, templateValues)
return c.Cmd.NewShell(command).Run()
diff --git a/pkg/gui/branches_panel.go b/pkg/gui/branches_panel.go
index 072ee257b..7fcf050b3 100644
--- a/pkg/gui/branches_panel.go
+++ b/pkg/gui/branches_panel.go
@@ -79,7 +79,7 @@ func (gui *Gui) handleCopyPullRequestURLPress() error {
return gui.c.Error(err)
}
gui.c.LogAction(gui.c.Tr.Actions.CopyPullRequestURL)
- if err := gui.OSCommand.CopyToClipboard(url); err != nil {
+ if err := gui.os.CopyToClipboard(url); err != nil {
return gui.c.Error(err)
}
diff --git a/pkg/gui/controllers/files_helper.go b/pkg/gui/controllers/files_helper.go
index c3706cc72..35f388183 100644
--- a/pkg/gui/controllers/files_helper.go
+++ b/pkg/gui/controllers/files_helper.go
@@ -10,6 +10,7 @@ type IFilesHelper interface {
EditFile(filename string) error
EditFileAtLine(filename string, lineNumber int) error
OpenFile(filename string) error
+ OpenFileAtLine(filename string, lineNumber int) error
}
type FilesHelper struct {
@@ -49,8 +50,12 @@ func (self *FilesHelper) EditFileAtLine(filename string, lineNumber int) error {
}
func (self *FilesHelper) OpenFile(filename string) error {
+ return self.OpenFileAtLine(filename, 1)
+}
+
+func (self *FilesHelper) OpenFileAtLine(filename string, lineNumber int) error {
self.c.LogAction(self.c.Tr.Actions.OpenFile)
- if err := self.os.OpenFile(filename); err != nil {
+ if err := self.os.OpenFileAtLine(filename, lineNumber); err != nil {
return self.c.Error(err)
}
return nil
diff --git a/pkg/gui/custom_commands.go b/pkg/gui/custom_commands.go
index 8111dd06c..e32e5bb11 100644
--- a/pkg/gui/custom_commands.go
+++ b/pkg/gui/custom_commands.go
@@ -247,7 +247,7 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand
}
if customCommand.Subprocess {
- return gui.runSubprocessWithSuspenseAndRefresh(gui.OSCommand.Cmd.NewShell(cmdStr))
+ return gui.runSubprocessWithSuspenseAndRefresh(gui.os.Cmd.NewShell(cmdStr))
}
loadingText := customCommand.LoadingText
@@ -256,7 +256,7 @@ func (gui *Gui) handleCustomCommandKeybinding(customCommand config.CustomCommand
}
return gui.c.WithWaitingStatus(loadingText, func() error {
gui.c.LogAction(gui.c.Tr.Actions.CustomCommand)
- cmdObj := gui.OSCommand.Cmd.NewShell(cmdStr)
+ cmdObj := gui.os.Cmd.NewShell(cmdStr)
if customCommand.Stream {
cmdObj.StreamOutput()
}
diff --git a/pkg/gui/diffing.go b/pkg/gui/diffing.go
index 30af99882..a23772ab3 100644
--- a/pkg/gui/diffing.go
+++ b/pkg/gui/diffing.go
@@ -15,7 +15,7 @@ func (gui *Gui) exitDiffMode() error {
}
func (gui *Gui) renderDiff() error {
- cmdObj := gui.OSCommand.Cmd.New(
+ cmdObj := gui.os.Cmd.New(
fmt.Sprintf("git diff --submodule --no-ext-diff --color %s", gui.diffStr()),
)
task := NewRunPtyTask(cmdObj.GetCmd())
diff --git a/pkg/gui/global_handlers.go b/pkg/gui/global_handlers.go
index ba8a0a237..d14c5193d 100644
--- a/pkg/gui/global_handlers.go
+++ b/pkg/gui/global_handlers.go
@@ -219,7 +219,7 @@ func (gui *Gui) handleCopySelectedSideContextItemToClipboard() error {
}
gui.c.LogAction(gui.c.Tr.Actions.CopyToClipboard)
- if err := gui.OSCommand.CopyToClipboard(itemId); err != nil {
+ if err := gui.os.CopyToClipboard(itemId); err != nil {
return gui.c.Error(err)
}
diff --git a/pkg/gui/gpg.go b/pkg/gui/gpg.go
index a469b2a61..60d728c42 100644
--- a/pkg/gui/gpg.go
+++ b/pkg/gui/gpg.go
@@ -18,7 +18,7 @@ func (gui *Gui) withGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus string,
useSubprocess := gui.git.Config.UsingGpg()
if useSubprocess {
- success, err := gui.runSubprocessWithSuspense(gui.OSCommand.Cmd.NewShell(cmdObj.ToString()))
+ success, err := gui.runSubprocessWithSuspense(gui.os.Cmd.NewShell(cmdObj.ToString()))
if success && onSuccess != nil {
if err := onSuccess(); err != nil {
return err
@@ -36,7 +36,7 @@ func (gui *Gui) withGpgHandling(cmdObj oscommands.ICmdObj, waitingStatus string,
func (gui *Gui) RunAndStream(cmdObj oscommands.ICmdObj, waitingStatus string, onSuccess func() error) error {
return gui.c.WithWaitingStatus(waitingStatus, func() error {
- cmdObj := gui.OSCommand.Cmd.NewShell(cmdObj.ToString())
+ cmdObj := gui.os.Cmd.NewShell(cmdObj.ToString())
cmdObj.AddEnvVars("TERM=dumb")
cmdWriter := gui.getCmdWriter()
cmd := cmdObj.GetCmd()
diff --git a/pkg/gui/gui.go b/pkg/gui/gui.go
index 3cc6129e3..9038fe647 100644
--- a/pkg/gui/gui.go
+++ b/pkg/gui/gui.go
@@ -83,9 +83,9 @@ type Repo string
// Gui wraps the gocui Gui object which handles rendering and events
type Gui struct {
*common.Common
- g *gocui.Gui
- git *commands.GitCommand
- OSCommand *oscommands.OSCommand
+ g *gocui.Gui
+ git *commands.GitCommand
+ os *oscommands.OSCommand
// this is the state of the GUI for the current repo
State *GuiRepoState
@@ -318,7 +318,7 @@ func (gui *Gui) onNewRepo(filterPath string, reuseState bool) error {
var err error
gui.git, err = commands.NewGitCommand(
gui.Common,
- gui.OSCommand,
+ gui.os,
git_config.NewStdCachedGitConfig(gui.Log),
gui.Mutexes.SyncMutex,
)
@@ -479,7 +479,7 @@ func NewGui(
osCommand := oscommands.NewOSCommand(cmn, oscommands.GetPlatform(), guiIO)
- gui.OSCommand = osCommand
+ gui.os = osCommand
gui.watchFilesForChanges()
@@ -509,7 +509,7 @@ func NewGui(
func (gui *Gui) resetControllers() {
controllerCommon := gui.c
- osCommand := gui.OSCommand
+ osCommand := gui.os
rebaseHelper := controllers.NewRebaseHelper(controllerCommon, gui.State.Contexts, gui.git, gui.takeOverMergeConflictScrolling)
model := gui.State.Model
gui.helpers = &Helpers{
@@ -977,7 +977,7 @@ func (gui *Gui) loadNewRepo() error {
return err
}
- if err := gui.OSCommand.UpdateWindowTitle(); err != nil {
+ if err := gui.os.UpdateWindowTitle(); err != nil {
return err
}
diff --git a/pkg/gui/information_panel.go b/pkg/gui/information_panel.go
index 07e64fb42..3e317a349 100644
--- a/pkg/gui/information_panel.go
+++ b/pkg/gui/information_panel.go
@@ -44,9 +44,9 @@ func (gui *Gui) handleInfoClick() error {
// if we're not in an active mode we show the donate button
if cx <= len(gui.c.Tr.Donate) {
- return gui.OSCommand.OpenLink(constants.Links.Donate)
+ return gui.os.OpenLink(constants.Links.Donate)
} else if cx <= len(gui.c.Tr.Donate)+1+len(gui.c.Tr.AskQuestion) {
- return gui.OSCommand.OpenLink(constants.Links.Discussions)
+ return gui.os.OpenLink(constants.Links.Discussions)
}
return nil
}
diff --git a/pkg/gui/line_by_line_panel.go b/pkg/gui/line_by_line_panel.go
index e9cace6d8..7f423f115 100644
--- a/pkg/gui/line_by_line_panel.go
+++ b/pkg/gui/line_by_line_panel.go
@@ -88,7 +88,7 @@ func (gui *Gui) copySelectedToClipboard() error {
selected := state.PlainRenderSelected()
gui.c.LogAction(gui.c.Tr.Actions.CopySelectedTextToClipboard)
- if err := gui.OSCommand.CopyToClipboard(selected); err != nil {
+ if err := gui.os.CopyToClipboard(selected); err != nil {
return gui.c.Error(err)
}
@@ -210,7 +210,7 @@ func (gui *Gui) handleOpenFileAtLine() error {
// need to look at current index, then work out what my hunk's header information is, and see how far my line is away from the hunk header
lineNumber := state.CurrentLineNumber()
- if err := gui.editFileAtLine(filename, lineNumber); err != nil {
+ if err := gui.os.OpenFileAtLine(filename, lineNumber); err != nil {
return err
}
diff --git a/pkg/gui/pull_request_menu_panel.go b/pkg/gui/pull_request_menu_panel.go
index 10f7bcdf5..1f63c6306 100644
--- a/pkg/gui/pull_request_menu_panel.go
+++ b/pkg/gui/pull_request_menu_panel.go
@@ -64,7 +64,7 @@ func (gui *Gui) createPullRequest(from string, to string) error {
gui.c.LogAction(gui.c.Tr.Actions.OpenPullRequest)
- if err := gui.OSCommand.OpenLink(url); err != nil {
+ if err := gui.os.OpenLink(url); err != nil {
return gui.c.Error(err)
}
diff --git a/pkg/gui/quitting.go b/pkg/gui/quitting.go
index 4db28dcb1..99ebdfb1a 100644
--- a/pkg/gui/quitting.go
+++ b/pkg/gui/quitting.go
@@ -25,7 +25,7 @@ func (gui *Gui) recordDirectory(dirName string) error {
if newDirFilePath == "" {
return nil
}
- return gui.OSCommand.CreateFileWithContent(newDirFilePath, dirName)
+ return gui.os.CreateFileWithContent(newDirFilePath, dirName)
}
func (gui *Gui) handleQuitWithoutChangingDirectory() error {
diff --git a/pkg/gui/recent_repos_panel.go b/pkg/gui/recent_repos_panel.go
index 16b6b1df9..73ee784c3 100644
--- a/pkg/gui/recent_repos_panel.go
+++ b/pkg/gui/recent_repos_panel.go
@@ -62,7 +62,7 @@ func (gui *Gui) dispatchSwitchToRepo(path string, reuse bool) error {
return err
}
- if err := commands.VerifyInGitRepo(gui.OSCommand); err != nil {
+ if err := commands.VerifyInGitRepo(gui.os); err != nil {
if err := os.Chdir(originalPath); err != nil {
return err
}