fix btw cursor row and column alignment
- commit
- fb3e1afa802373c7a6149287ba492eaccbdb59b9
- author
- patriceckhart · · 2026-05-26 16:55 UTC
- parent
- d55af26
- signature
- unsigned
- refs
- tag: v0.1.99
1 file · +10 -3
M internal/agent/modes/btw_dialog.go +10 -3
| @@ -348,7 +348,10 @@ func (d *btwDialog) Render(th tui.Theme, width int) []string { | |||
| 348 | 348 | ||
| 349 | 349 | out = append(out, "") | |
| 350 | 350 | if d.editor != nil { | |
| 351 | - | edLines, _, _ := d.editor.Render(width) | |
| 351 | + | // Render at width-2 to match the two-cell left indent applied | |
| 352 | + | // below. CursorPos uses the same width so the reported cursor | |
| 353 | + | // column matches the wrapped layout shown on screen. | |
| 354 | + | edLines, _, _ := d.editor.Render(width - 2) | |
| 352 | 355 | for _, l := range edLines { | |
| 353 | 356 | // Indent the editor body so it lines up with the side-chat | |
| 354 | 357 | // content column. Editor's prompt already includes a left | |
| @@ -371,9 +374,13 @@ func (d *btwDialog) CursorPos(width int) (row, col int) { | |||
| 371 | 374 | if !d.active || d.editor == nil { | |
| 372 | 375 | return -1, -1 | |
| 373 | 376 | } | |
| 374 | - | // Reproduce render's structure to find where the editor sits: | |
| 375 | - | // header (1) + (turns_section_lines) + (loading?) + blank (1) + editor | |
| 377 | + | // Reproduce render's structure to find where the editor sits. | |
| 378 | + | // Note: the parent (interactive.go) wraps every dialog with | |
| 379 | + | // padDialogFrame, which injects a blank row right after the | |
| 380 | + | // frame header. We have to count that injected row here too; | |
| 381 | + | // otherwise the reported cursor lands one row above the editor. | |
| 376 | 382 | editorOffset := 1 // header | |
| 383 | + | editorOffset++ // padDialogFrame's post-header blank | |
| 377 | 384 | if len(d.turns) == 0 && !d.loading { | |
| 378 | 385 | editorOffset++ // muted "ask anything..." line | |
| 379 | 386 | } | |
| @@ -348,7 +348,10 @@ func (d *btwDialog) Render(th tui.Theme, width int) []string { | |||||
| 348 | 348 | ||||
| 349 | out = append(out, "") | 349 | out = append(out, "") | ||
| 350 | if d.editor != nil { | 350 | if d.editor != nil { | ||
| 351 | - | edLines, _, _ := d.editor.Render(width) | 351 | + | // Render at width-2 to match the two-cell left indent applied |
| 352 | + | // below. CursorPos uses the same width so the reported cursor | |||
| 353 | + | // column matches the wrapped layout shown on screen. | |||
| 354 | + | edLines, _, _ := d.editor.Render(width - 2) | |||
| 352 | for _, l := range edLines { | 355 | for _, l := range edLines { | ||
| 353 | // Indent the editor body so it lines up with the side-chat | 356 | // Indent the editor body so it lines up with the side-chat | ||
| 354 | // content column. Editor's prompt already includes a left | 357 | // content column. Editor's prompt already includes a left | ||
| @@ -371,9 +374,13 @@ func (d *btwDialog) CursorPos(width int) (row, col int) { | |||||
| 371 | if !d.active || d.editor == nil { | 374 | if !d.active || d.editor == nil { | ||
| 372 | return -1, -1 | 375 | return -1, -1 | ||
| 373 | } | 376 | } | ||
| 374 | - | // Reproduce render's structure to find where the editor sits: | 377 | + | // Reproduce render's structure to find where the editor sits. |
| 375 | - | // header (1) + (turns_section_lines) + (loading?) + blank (1) + editor | 378 | + | // Note: the parent (interactive.go) wraps every dialog with |
| 379 | + | // padDialogFrame, which injects a blank row right after the | |||
| 380 | + | // frame header. We have to count that injected row here too; | |||
| 381 | + | // otherwise the reported cursor lands one row above the editor. | |||
| 376 | editorOffset := 1 // header | 382 | editorOffset := 1 // header | ||
| 383 | + | editorOffset++ // padDialogFrame's post-header blank | |||
| 377 | if len(d.turns) == 0 && !d.loading { | 384 | if len(d.turns) == 0 && !d.loading { | ||
| 378 | editorOffset++ // muted "ask anything..." line | 385 | editorOffset++ // muted "ask anything..." line | ||
| 379 | } | 386 | } | ||