mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	Fix window arrangement when a popup or the search prompt is open (#4961)
When focusing the main view, going into full screen mode by pressing '+'
twice, and then opening the search prompt ('/') or a menu (e.g. '?' or
':'), the full screen display would switch to the focused side panel.
Fix this by always excluding popups from the window arrangement logic.
No popup should ever have any influence on how the views beneath it are
laid out.
Addresses [this detail
aspect](https://github.com/jesseduffield/lazygit/issues/1113#issuecomment-3206883422)
of #1113.
			
			
This commit is contained in:
		| @@ -43,10 +43,9 @@ type WindowArrangementArgs struct { | |||||||
| 	Height int | 	Height int | ||||||
| 	// User config | 	// User config | ||||||
| 	UserConfig *config.UserConfig | 	UserConfig *config.UserConfig | ||||||
| 	// Name of the currently focused window | 	// Name of the currently focused window. (It's actually the current static window, meaning | ||||||
|  | 	// popups are ignored) | ||||||
| 	CurrentWindow string | 	CurrentWindow string | ||||||
| 	// Name of the current static window (meaning popups are ignored) |  | ||||||
| 	CurrentStaticWindow string |  | ||||||
| 	// Name of the current side window (i.e. the current window in the left | 	// Name of the current side window (i.e. the current window in the left | ||||||
| 	// section of the UI) | 	// section of the UI) | ||||||
| 	CurrentSideWindow string | 	CurrentSideWindow string | ||||||
| @@ -86,21 +85,20 @@ func (self *WindowArrangementHelper) GetWindowDimensions(informationStr string, | |||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	args := WindowArrangementArgs{ | 	args := WindowArrangementArgs{ | ||||||
| 		Width:               width, | 		Width:             width, | ||||||
| 		Height:              height, | 		Height:            height, | ||||||
| 		UserConfig:          self.c.UserConfig(), | 		UserConfig:        self.c.UserConfig(), | ||||||
| 		CurrentWindow:       self.windowHelper.CurrentWindow(), | 		CurrentWindow:     self.c.Context().CurrentStatic().GetWindowName(), | ||||||
| 		CurrentSideWindow:   self.c.Context().CurrentSide().GetWindowName(), | 		CurrentSideWindow: self.c.Context().CurrentSide().GetWindowName(), | ||||||
| 		CurrentStaticWindow: self.c.Context().CurrentStatic().GetWindowName(), | 		SplitMainPanel:    repoState.GetSplitMainPanel(), | ||||||
| 		SplitMainPanel:      repoState.GetSplitMainPanel(), | 		ScreenMode:        repoState.GetScreenMode(), | ||||||
| 		ScreenMode:          repoState.GetScreenMode(), | 		AppStatus:         appStatus, | ||||||
| 		AppStatus:           appStatus, | 		InformationStr:    informationStr, | ||||||
| 		InformationStr:      informationStr, | 		ShowExtrasWindow:  self.c.State().GetShowExtrasWindow(), | ||||||
| 		ShowExtrasWindow:    self.c.State().GetShowExtrasWindow(), | 		InDemo:            self.c.InDemo(), | ||||||
| 		InDemo:              self.c.InDemo(), | 		IsAnyModeActive:   self.modeHelper.IsAnyModeActive(), | ||||||
| 		IsAnyModeActive:     self.modeHelper.IsAnyModeActive(), | 		InSearchPrompt:    repoState.InSearchPrompt(), | ||||||
| 		InSearchPrompt:      repoState.InSearchPrompt(), | 		SearchPrefix:      searchPrefix, | ||||||
| 		SearchPrefix:        searchPrefix, |  | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
| 	return GetWindowDimensions(args) | 	return GetWindowDimensions(args) | ||||||
| @@ -393,7 +391,7 @@ func splitMainPanelSideBySide(args WindowArrangementArgs) bool { | |||||||
| func getExtrasWindowSize(args WindowArrangementArgs) int { | func getExtrasWindowSize(args WindowArrangementArgs) int { | ||||||
| 	var baseSize int | 	var baseSize int | ||||||
| 	// The 'extras' window contains the command log context | 	// The 'extras' window contains the command log context | ||||||
| 	if args.CurrentStaticWindow == "extras" { | 	if args.CurrentWindow == "extras" { | ||||||
| 		baseSize = 1000 // my way of saying 'fill the available space' | 		baseSize = 1000 // my way of saying 'fill the available space' | ||||||
| 	} else if args.Height < 40 { | 	} else if args.Height < 40 { | ||||||
| 		baseSize = 1 | 		baseSize = 1 | ||||||
|   | |||||||
| @@ -19,21 +19,20 @@ import ( | |||||||
| func TestGetWindowDimensions(t *testing.T) { | func TestGetWindowDimensions(t *testing.T) { | ||||||
| 	getDefaultArgs := func() WindowArrangementArgs { | 	getDefaultArgs := func() WindowArrangementArgs { | ||||||
| 		return WindowArrangementArgs{ | 		return WindowArrangementArgs{ | ||||||
| 			Width:               75, | 			Width:             75, | ||||||
| 			Height:              30, | 			Height:            30, | ||||||
| 			UserConfig:          config.GetDefaultConfig(), | 			UserConfig:        config.GetDefaultConfig(), | ||||||
| 			CurrentWindow:       "files", | 			CurrentWindow:     "files", | ||||||
| 			CurrentSideWindow:   "files", | 			CurrentSideWindow: "files", | ||||||
| 			CurrentStaticWindow: "files", | 			SplitMainPanel:    false, | ||||||
| 			SplitMainPanel:      false, | 			ScreenMode:        types.SCREEN_NORMAL, | ||||||
| 			ScreenMode:          types.SCREEN_NORMAL, | 			AppStatus:         "", | ||||||
| 			AppStatus:           "", | 			InformationStr:    "information", | ||||||
| 			InformationStr:      "information", | 			ShowExtrasWindow:  false, | ||||||
| 			ShowExtrasWindow:    false, | 			InDemo:            false, | ||||||
| 			InDemo:              false, | 			IsAnyModeActive:   false, | ||||||
| 			IsAnyModeActive:     false, | 			InSearchPrompt:    false, | ||||||
| 			InSearchPrompt:      false, | 			SearchPrefix:      "", | ||||||
| 			SearchPrefix:        "", |  | ||||||
| 		} | 		} | ||||||
| 	} | 	} | ||||||
|  |  | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user