mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-02-09 13:47:11 +02:00
support some more things
This commit is contained in:
parent
418621a9ff
commit
c9de6c003b
@ -203,3 +203,11 @@ func (s *StatusLineNode) GetPathsMatching(test func(*StatusLineNode) bool) []str
|
||||
|
||||
return paths
|
||||
}
|
||||
|
||||
func (s *StatusLineNode) ID() string {
|
||||
return s.GetPath()
|
||||
}
|
||||
|
||||
func (s *StatusLineNode) Description() string {
|
||||
return s.GetPath()
|
||||
}
|
||||
|
@ -16,6 +16,7 @@ type CustomCommandObjects struct {
|
||||
SelectedReflogCommit *models.Commit
|
||||
SelectedSubCommit *models.Commit
|
||||
SelectedFile *models.File
|
||||
SelectedPath string
|
||||
SelectedLocalBranch *models.Branch
|
||||
SelectedRemoteBranch *models.RemoteBranch
|
||||
SelectedRemote *models.Remote
|
||||
@ -29,6 +30,7 @@ type CustomCommandObjects struct {
|
||||
func (gui *Gui) resolveTemplate(templateStr string, promptResponses []string) (string, error) {
|
||||
objects := CustomCommandObjects{
|
||||
SelectedFile: gui.getSelectedFile(),
|
||||
SelectedPath: gui.getSelectedPath(),
|
||||
SelectedLocalCommit: gui.getSelectedLocalCommit(),
|
||||
SelectedReflogCommit: gui.getSelectedReflogCommit(),
|
||||
SelectedLocalBranch: gui.getSelectedBranch(),
|
||||
|
@ -43,6 +43,15 @@ func (gui *Gui) getSelectedFile() *models.File {
|
||||
return node.File
|
||||
}
|
||||
|
||||
func (gui *Gui) getSelectedPath() string {
|
||||
node := gui.getSelectedStatusNode()
|
||||
if node == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return node.GetPath()
|
||||
}
|
||||
|
||||
func (gui *Gui) selectFile(alreadySelected bool) error {
|
||||
gui.getFilesView().FocusPoint(0, gui.State.Panels.Files.SelectedLineIdx)
|
||||
|
||||
@ -104,7 +113,7 @@ func (gui *Gui) refreshFilesAndSubmodules() error {
|
||||
gui.Mutexes.RefreshingFilesMutex.Unlock()
|
||||
}()
|
||||
|
||||
selectedFile := gui.getSelectedFile()
|
||||
selectedPath := gui.getSelectedPath()
|
||||
|
||||
filesView := gui.getFilesView()
|
||||
if filesView == nil {
|
||||
@ -131,8 +140,8 @@ func (gui *Gui) refreshFilesAndSubmodules() error {
|
||||
}
|
||||
|
||||
if gui.currentContext().GetKey() == FILES_CONTEXT_KEY || (g.CurrentView() == gui.getMainView() && g.CurrentView().Context == MAIN_MERGING_CONTEXT_KEY) {
|
||||
newSelectedFile := gui.getSelectedFile()
|
||||
alreadySelected := selectedFile != nil && newSelectedFile != nil && newSelectedFile.Name == selectedFile.Name
|
||||
newSelectedPath := gui.getSelectedPath()
|
||||
alreadySelected := selectedPath != "" && newSelectedPath == selectedPath
|
||||
if err := gui.selectFile(alreadySelected); err != nil {
|
||||
return err
|
||||
}
|
||||
@ -461,20 +470,25 @@ func (gui *Gui) editFile(filename string) error {
|
||||
}
|
||||
|
||||
func (gui *Gui) handleFileEdit(g *gocui.Gui, v *gocui.View) error {
|
||||
file := gui.getSelectedFile()
|
||||
if file == nil {
|
||||
node := gui.getSelectedStatusNode()
|
||||
if node == nil {
|
||||
return nil
|
||||
}
|
||||
|
||||
return gui.editFile(file.Name)
|
||||
if node.File == nil {
|
||||
return gui.createErrorPanel(gui.Tr.ErrCannotEditDirectory)
|
||||
}
|
||||
|
||||
return gui.editFile(node.GetPath())
|
||||
}
|
||||
|
||||
func (gui *Gui) handleFileOpen(g *gocui.Gui, v *gocui.View) error {
|
||||
file := gui.getSelectedFile()
|
||||
if file == nil {
|
||||
node := gui.getSelectedStatusNode()
|
||||
if node == nil {
|
||||
return nil
|
||||
}
|
||||
return gui.openFile(file.Name)
|
||||
|
||||
return gui.openFile(node.GetPath())
|
||||
}
|
||||
|
||||
func (gui *Gui) handleRefreshFiles(g *gocui.Gui, v *gocui.View) error {
|
||||
|
@ -278,10 +278,11 @@ func (gui *Gui) filesListContext() *ListContext {
|
||||
|
||||
return mappedLines
|
||||
|
||||
// TODO: Fix this up
|
||||
return presentation.GetFileListDisplayStrings(gui.State.StatusLineManager.GetAllFiles(), gui.State.Modes.Diffing.Ref, gui.State.Submodules)
|
||||
},
|
||||
SelectedItem: func() (ListItem, bool) {
|
||||
item := gui.getSelectedFile()
|
||||
item := gui.getSelectedStatusNode()
|
||||
return item, item != nil
|
||||
},
|
||||
}
|
||||
|
@ -435,6 +435,7 @@ type TranslationSet struct {
|
||||
PullRequestURLCopiedToClipboard string
|
||||
CommitMessageCopiedToClipboard string
|
||||
LcCopiedToClipboard string
|
||||
ErrCannotEditDirectory string
|
||||
}
|
||||
|
||||
const englishReleaseNotes = `## lazygit 0.26 Release Notes
|
||||
@ -993,5 +994,6 @@ func englishTranslationSet() TranslationSet {
|
||||
PullRequestURLCopiedToClipboard: "Pull request URL copied to clipboard",
|
||||
CommitMessageCopiedToClipboard: "Commit message copied to clipboard",
|
||||
LcCopiedToClipboard: "copied to clipboard",
|
||||
ErrCannotEditDirectory: "Cannot edit directory: you can only edit individual files",
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user