mirror of
https://github.com/jesseduffield/lazygit.git
synced 2025-11-25 22:32:13 +02:00
Refactor: add a separate Prompt view
So far, confirmations and prompts were handled by the same view, context, and controller, with a bunch of conditional code based on whether the view is editable. This was more or less ok so far, since it does save a little bit of code duplication; however, now we need separate views, because we don't have dynamic keybindings, but we want to map "confirm" to different keys in confirmations (the "universal.confirm" user config) and prompts (hard-coded to enter, because it doesn't make sense to customize it there). It also allows us to get rid of the conditional code, which is a nice benefit; and the code duplication is actually not *that* bad.
This commit is contained in:
@@ -13,7 +13,7 @@ func (self *Popup) Confirmation() *ConfirmationDriver {
|
||||
func (self *Popup) inConfirm() {
|
||||
self.t.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.t.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && !currentView.Editable, "Expected confirmation popup to be focused"
|
||||
return currentView.Name() == "confirmation", "Expected confirmation popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ func (self *Popup) Prompt() *PromptDriver {
|
||||
func (self *Popup) inPrompt() {
|
||||
self.t.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.t.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && currentView.Editable, "Expected prompt popup to be focused"
|
||||
return currentView.Name() == "prompt", "Expected prompt popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
@@ -45,7 +45,7 @@ func (self *Popup) inAlert() {
|
||||
// basically the same thing as a confirmation popup with the current implementation
|
||||
self.t.assertWithRetries(func() (bool, string) {
|
||||
currentView := self.t.gui.CurrentContext().GetView()
|
||||
return currentView.Name() == "confirmation" && !currentView.Editable, "Expected alert popup to be focused"
|
||||
return currentView.Name() == "confirmation", "Expected alert popup to be focused"
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ type PromptDriver struct {
|
||||
}
|
||||
|
||||
func (self *PromptDriver) getViewDriver() *ViewDriver {
|
||||
return self.t.Views().Confirmation()
|
||||
return self.t.Views().Prompt()
|
||||
}
|
||||
|
||||
// asserts that the popup has the expected title
|
||||
|
||||
@@ -128,6 +128,10 @@ func (self *Views) Confirmation() *ViewDriver {
|
||||
return self.regularView("confirmation")
|
||||
}
|
||||
|
||||
func (self *Views) Prompt() *ViewDriver {
|
||||
return self.regularView("prompt")
|
||||
}
|
||||
|
||||
func (self *Views) CommitMessage() *ViewDriver {
|
||||
return self.regularView("commitMessage")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user