mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-05-27 23:08:02 +02:00
ensure there is always a current context
This commit is contained in:
parent
ade54b38c1
commit
4198bbae6c
@ -85,7 +85,7 @@ func (gui *Gui) refreshCommits() error {
|
||||
|
||||
go func() {
|
||||
_ = gui.refreshCommitsWithLimit()
|
||||
if gui.g.CurrentView() == gui.getCommitFilesView() || (gui.currentContextKey() == gui.Contexts.PatchBuilding.Context.GetKey()) {
|
||||
if gui.g.CurrentView() == gui.getCommitFilesView() || (gui.currentContext().GetKey() == gui.Contexts.PatchBuilding.Context.GetKey()) {
|
||||
_ = gui.refreshCommitFilesView()
|
||||
}
|
||||
wg.Done()
|
||||
|
@ -493,20 +493,9 @@ func (gui *Gui) renderContextStack() string {
|
||||
return result
|
||||
}
|
||||
|
||||
func (gui *Gui) currentContextKey() string {
|
||||
currentContext := gui.currentContext()
|
||||
|
||||
if currentContext == nil {
|
||||
return ""
|
||||
}
|
||||
|
||||
return currentContext.GetKey()
|
||||
}
|
||||
|
||||
func (gui *Gui) currentContext() Context {
|
||||
// on startup the stack can be empty so we'll return an empty string in that case
|
||||
if len(gui.State.ContextStack) == 0 {
|
||||
return nil
|
||||
return gui.defaultSideContext()
|
||||
}
|
||||
|
||||
return gui.State.ContextStack[len(gui.State.ContextStack)-1]
|
||||
|
@ -31,7 +31,7 @@ func (gui *Gui) renderDiff() error {
|
||||
// which becomes an option when you bring up the diff menu, but when you're just
|
||||
// flicking through branches it will be using the local branch name.
|
||||
func (gui *Gui) currentDiffTerminals() []string {
|
||||
switch gui.currentContextKey() {
|
||||
switch gui.currentContext().GetKey() {
|
||||
case "":
|
||||
return nil
|
||||
case FILES_CONTEXT_KEY:
|
||||
@ -71,7 +71,7 @@ func (gui *Gui) currentDiffTerminal() string {
|
||||
}
|
||||
|
||||
func (gui *Gui) currentlySelectedFilename() string {
|
||||
switch gui.currentContextKey() {
|
||||
switch gui.currentContext().GetKey() {
|
||||
case FILES_CONTEXT_KEY, COMMIT_FILES_CONTEXT_KEY:
|
||||
return gui.getSideContextSelectedItemId()
|
||||
default:
|
||||
|
@ -234,7 +234,7 @@ func (gui *Gui) refreshMainViewForLineByLine() error {
|
||||
var includedLineIndices []int
|
||||
// I'd prefer not to have knowledge of contexts using this file but I'm not sure
|
||||
// how to get around this
|
||||
if gui.currentContextKey() == gui.Contexts.PatchBuilding.Context.GetKey() {
|
||||
if gui.currentContext().GetKey() == gui.Contexts.PatchBuilding.Context.GetKey() {
|
||||
filename := gui.getSelectedCommitFileName()
|
||||
var err error
|
||||
includedLineIndices, err = gui.GitCommand.PatchManager.GetFileIncLineIndices(filename)
|
||||
|
Loading…
x
Reference in New Issue
Block a user