mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	Merge pull request #260 from jesseduffield/hotfix/258-commit-message-newlines
Fix popup panel resizing
This commit is contained in:
		
							
								
								
									
										5
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										5
									
								
								Gopkg.lock
									
									
									
										generated
									
									
									
								
							| @@ -189,11 +189,11 @@ | ||||
|  | ||||
| [[projects]] | ||||
|   branch = "master" | ||||
|   digest = "1:acbcdae312c37a8019e0f573a9be26499058d5e1244243655373d2fd97714658" | ||||
|   digest = "1:145fe566d21b0e2579e1600f09e4e4b01da017676ba8e079de75a2e21111538b" | ||||
|   name = "github.com/jesseduffield/gocui" | ||||
|   packages = ["."] | ||||
|   pruneopts = "NUT" | ||||
|   revision = "5d9e836837237cb3aadca51ecb37c7cf3345bfa4" | ||||
|   revision = "c4051ef0fbcbe519bc1d082a579a38100c7cf044" | ||||
|  | ||||
| [[projects]] | ||||
|   digest = "1:ac6d01547ec4f7f673311b4663909269bfb8249952de3279799289467837c3cc" | ||||
| @@ -611,7 +611,6 @@ | ||||
|   analyzer-version = 1 | ||||
|   input-imports = [ | ||||
|     "github.com/cloudfoundry/jibber_jabber", | ||||
|     "github.com/davecgh/go-spew/spew", | ||||
|     "github.com/fatih/color", | ||||
|     "github.com/golang-collections/collections/stack", | ||||
|     "github.com/heroku/rollrus", | ||||
|   | ||||
| @@ -34,15 +34,6 @@ func (gui *Gui) handleCommitClose(g *gocui.Gui, v *gocui.View) error { | ||||
| } | ||||
|  | ||||
| func (gui *Gui) handleNewlineCommitMessage(g *gocui.Gui, v *gocui.View) error { | ||||
| 	// resising ahead of time so that the top line doesn't get hidden to make | ||||
| 	// room for the cursor on the second line | ||||
| 	x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, v.Buffer()) | ||||
| 	if _, err := g.SetView("commitMessage", x0, y0, x1, y1+1, 0); err != nil { | ||||
| 		if err != gocui.ErrUnknownView { | ||||
| 			return err | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	v.EditNewLine() | ||||
| 	return nil | ||||
| } | ||||
|   | ||||
| @@ -11,7 +11,6 @@ import ( | ||||
|  | ||||
| 	"github.com/fatih/color" | ||||
| 	"github.com/jesseduffield/gocui" | ||||
| 	"github.com/jesseduffield/lazygit/pkg/utils" | ||||
| ) | ||||
|  | ||||
| func (gui *Gui) wrappedConfirmationFunction(function func(*gocui.Gui, *gocui.View) error) func(*gocui.Gui, *gocui.View) error { | ||||
| @@ -161,17 +160,3 @@ func (gui *Gui) createErrorPanel(g *gocui.Gui, message string) error { | ||||
| 	coloredMessage := colorFunction(strings.TrimSpace(message)) | ||||
| 	return gui.createConfirmationPanel(g, currentView, gui.Tr.SLocalize("Error"), coloredMessage, nil, nil) | ||||
| } | ||||
|  | ||||
| func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error { | ||||
| 	// If the confirmation panel is already displayed, just resize the width, | ||||
| 	// otherwise continue | ||||
| 	content := utils.TrimTrailingNewline(v.Buffer()) | ||||
| 	x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content) | ||||
| 	vx0, vy0, vx1, vy1 := v.Dimensions() | ||||
| 	if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 { | ||||
| 		return nil | ||||
| 	} | ||||
| 	gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel")) | ||||
| 	_, err := g.SetView(v.Name(), x0, y0, x1, y1, 0) | ||||
| 	return err | ||||
| } | ||||
|   | ||||
| @@ -307,9 +307,7 @@ func (gui *Gui) layout(g *gocui.Gui) error { | ||||
| 		} | ||||
| 	} | ||||
|  | ||||
| 	gui.resizePopupPanels(g) | ||||
|  | ||||
| 	return nil | ||||
| 	return gui.resizeCurrentPopupPanel(g) | ||||
| } | ||||
|  | ||||
| func (gui *Gui) promptAnonymousReporting() error { | ||||
| @@ -355,14 +353,6 @@ func (gui *Gui) goEvery(g *gocui.Gui, interval time.Duration, function func(*goc | ||||
| 	}() | ||||
| } | ||||
|  | ||||
| func (gui *Gui) resizePopupPanels(g *gocui.Gui) error { | ||||
| 	v := g.CurrentView() | ||||
| 	if v.Name() == "commitMessage" || v.Name() == "confirmation" { | ||||
| 		return gui.resizePopupPanel(g, v) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| // Run setup the gui with keybindings and start the mainloop | ||||
| func (gui *Gui) Run() error { | ||||
| 	g, err := gocui.NewGui(gocui.OutputNormal, OverlappingEdges) | ||||
|   | ||||
| @@ -268,3 +268,25 @@ func (gui *Gui) currentViewName(g *gocui.Gui) string { | ||||
| 	currentView := g.CurrentView() | ||||
| 	return currentView.Name() | ||||
| } | ||||
|  | ||||
| func (gui *Gui) resizeCurrentPopupPanel(g *gocui.Gui) error { | ||||
| 	v := g.CurrentView() | ||||
| 	if v.Name() == "commitMessage" || v.Name() == "confirmation" { | ||||
| 		return gui.resizePopupPanel(g, v) | ||||
| 	} | ||||
| 	return nil | ||||
| } | ||||
|  | ||||
| func (gui *Gui) resizePopupPanel(g *gocui.Gui, v *gocui.View) error { | ||||
| 	// If the confirmation panel is already displayed, just resize the width, | ||||
| 	// otherwise continue | ||||
| 	content := v.Buffer() | ||||
| 	x0, y0, x1, y1 := gui.getConfirmationPanelDimensions(g, content) | ||||
| 	vx0, vy0, vx1, vy1 := v.Dimensions() | ||||
| 	if vx0 == x0 && vy0 == y0 && vx1 == x1 && vy1 == y1 { | ||||
| 		return nil | ||||
| 	} | ||||
| 	gui.Log.Info(gui.Tr.SLocalize("resizingPopupPanel")) | ||||
| 	_, err := g.SetView(v.Name(), x0, y0, x1, y1, 0) | ||||
| 	return err | ||||
| } | ||||
|   | ||||
							
								
								
									
										2
									
								
								vendor/github.com/jesseduffield/gocui/edit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							
							
						
						
									
										2
									
								
								vendor/github.com/jesseduffield/gocui/edit.go
									
									
									
										generated
									
									
										vendored
									
									
								
							| @@ -114,8 +114,8 @@ func (v *View) EditDelete(back bool) { | ||||
| func (v *View) EditNewLine() { | ||||
| 	v.breakLine(v.cx, v.cy) | ||||
| 	v.ox = 0 | ||||
| 	v.cy = v.cy + 1 | ||||
| 	v.cx = 0 | ||||
| 	v.MoveCursor(0, 1, true) | ||||
| } | ||||
|  | ||||
| // MoveCursor moves the cursor taking into account the width of the line/view, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user