diff --git a/pkg/gui/commit_files_panel.go b/pkg/gui/commit_files_panel.go index 9854cfc77..cb41c4a25 100644 --- a/pkg/gui/commit_files_panel.go +++ b/pkg/gui/commit_files_panel.go @@ -218,9 +218,7 @@ func (gui *Gui) enterCommitFile(selectedLineIdx int) error { func (gui *Gui) switchToCommitFilesContext(refName string, isStash bool, context Context, windowName string) error { // sometimes the commitFiles view is already shown in another window, so we need to ensure that window // no longer considers the commitFiles view as its main view. - - window := gui.getWindowForViewName("commitFiles") - gui.State.WindowViewNameMap[window] = window + gui.resetWindowForView("commitFiles") gui.State.Panels.CommitFiles.SelectedLineIdx = 0 gui.State.Panels.CommitFiles.refName = refName diff --git a/pkg/gui/window.go b/pkg/gui/window.go index 8d2f3ff18..8931ff07b 100644 --- a/pkg/gui/window.go +++ b/pkg/gui/window.go @@ -34,3 +34,9 @@ func (gui *Gui) setViewAsActiveForWindow(viewName string) { func (gui *Gui) currentWindow() string { return gui.getWindowForViewName(gui.currentViewName()) } + +func (gui *Gui) resetWindowForView(viewName string) { + window := gui.getWindowForViewName(viewName) + // we assume here that the window contains as its default view a view with the same name as the window + gui.State.WindowViewNameMap[window] = window +}