mirror of
https://github.com/jesseduffield/lazygit.git
synced 2026-10-05 21:46:49 -04:00
Clear a pending newline when overwriting lines in place
OverwriteLines is asked for a line and writes the one below it when the write before it ended in a newline. The view holds such a newline back until more content arrives, so that it doesn't end in an empty line, and OverwriteLines moved the write cursor without letting go of it, so the write that followed advanced to the next line first. Move the cursor through SetWritePos, which drops the pending newline along with it. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5.1
parent
7c355a3801
commit
89e578123e
+1
-2
@@ -2263,8 +2263,7 @@ func (v *View) ClearTextArea() {
|
||||
|
||||
func (v *View) overwriteLines(y int, content string) {
|
||||
// break by newline, then for each line, write it, then add that erase command
|
||||
v.buf.wx = 0
|
||||
v.buf.wy = y
|
||||
v.SetWritePos(0, y)
|
||||
v.clearViewLines()
|
||||
|
||||
lines := strings.ReplaceAll(content, "\n", "\x1b[K\n")
|
||||
|
||||
@@ -121,10 +121,7 @@ func TestOverwriteLinesAfterContentEndingInANewline(t *testing.T) {
|
||||
|
||||
v.OverwriteLines(0, "x")
|
||||
|
||||
/* EXPECTED:
|
||||
assert.Equal(t, []string{"x", "b"}, v.BufferLines())
|
||||
ACTUAL: */
|
||||
assert.Equal(t, []string{"a", "x"}, v.BufferLines())
|
||||
}
|
||||
|
||||
func TestUpdatedCursorAndOrigin(t *testing.T) {
|
||||
|
||||
Reference in New Issue
Block a user