▍ humdrum codex / glint v1.0.2

refactor: goal column driven by ops, not lazy-init in vertical moves

85f2612987cf030601db655dc4a36d5a68a297bf
humdrum <me@humdrum.me> · 2026-06-28 11:08

parent bfbe78cf

refactor: goal column driven by ops, not lazy-init in vertical moves

Revert MoveUp/MoveDown to the brief's pure-read form (no goalCol==0
'unset' conflation); the two goal tests now call setGoal() directly,
matching how horizontal/edit ops drive the goal in the real app.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

2 files changed

internal/editor/editor.go +0 −8
@@ -177,10 +177,6 @@ 	ci := cursorVIndex(rows, e.Cursor)
 	if ci <= 0 {
 		return
 	}
-	// Initialize goal from current position if not yet set
-	if ci > 0 && e.goalCol == 0 {
-		e.goalCol = e.visualColOf(e.Cursor.Row, e.Cursor.Col)
-	}
 	e.applyGoal(rows[ci-1])
 	e.followCursor()
 }
@@ -191,10 +187,6 @@ 	rows := e.buildVisual()
 	ci := cursorVIndex(rows, e.Cursor)
 	if ci < 0 || ci+1 >= len(rows) {
 		return
-	}
-	// Initialize goal from current position if not yet set
-	if e.goalCol == 0 {
-		e.goalCol = e.visualColOf(e.Cursor.Row, e.Cursor.Col)
 	}
 	e.applyGoal(rows[ci+1])
 	e.followCursor()
internal/editor/editor_test.go +2 −0
@@ -224,6 +224,7 @@ 	e := New()
 	e.Lines = []string{"aaaa bbbb cccc"} // wraps at width 9 into ["aaaa ","bbbb cccc"]
 	e.SetSize(9, 10)
 	e.Cursor = Position{Row: 0, Col: 0}
+	e.setGoal()  // ops normally set the goal; set it directly here
 	e.MoveDown() // to the second visual row, goal column 0
 	if e.Cursor != (Position{Row: 0, Col: 5}) {
 		t.Errorf("after MoveDown: %+v, want {0 5}", e.Cursor)
@@ -239,6 +240,7 @@ 	e := New()
 	e.Lines = []string{"aaaa bbbb cccc"}
 	e.SetSize(9, 10)
 	e.Cursor = Position{Row: 0, Col: 2} // visual column 2 in segment 0
+	e.setGoal()                         // ops normally set the goal; set it directly here
 	e.MoveDown()                        // segment 1 starts at col 5 → col 5+2 = 7
 	if e.Cursor != (Position{Row: 0, Col: 7}) {
 		t.Errorf("after MoveDown with goal: %+v, want {0 7}", e.Cursor)