@@ -4,6 +4,7 @@ import (
44 "encoding/json"
55 "fmt"
66 "sort"
7+ "strconv"
78 "strings"
89 "time"
910
@@ -319,6 +320,12 @@ func (m *Model) applyToolResultMsg(msg llmToolResultMsg) {
319320 filePath = sm[1]
320321 }
321322
323+ // Extract start line from "(lines N-M)" for cursor positioning.
324+ var startLine int
325+ if sm := toolResultLineRe.FindStringSubmatch(msg.content); sm != nil {
326+ startLine, _ = strconv.Atoi(sm[1])
327+ }
328+
322329 lines := strings.Split(msg.content, "\n")
323330 preview := lines
324331 truncated := false
@@ -333,14 +340,14 @@ func (m *Model) applyToolResultMsg(msg llmToolResultMsg) {
333340 display := m.styles.Dim.Render(line)
334341 if i == 0 {
335342 display = arrow + display
336- wasBottom = m.appendConv(convEntry{display: display, kind: entryToolResult, filePath: filePath, full: msg.content})
343+ wasBottom = m.appendConv(convEntry{display: display, kind: entryToolResult, filePath: filePath, full: msg.content, line: startLine})
337344 } else {
338- m.appendConv(convEntry{display: display, kind: entryToolResult, filePath: filePath, full: msg.content})
345+ m.appendConv(convEntry{display: display, kind: entryToolResult, filePath: filePath, full: msg.content, line: startLine})
339346 }
340347 }
341348 if truncated {
342349 hint := fmt.Sprintf(" ... %d more lines (click to view)", len(lines)-maxPreviewLines)
343- m.appendConv(convEntry{display: m.styles.Muted.Render(hint), kind: entryToolResult, filePath: filePath, full: msg.content})
350+ m.appendConv(convEntry{display: m.styles.Muted.Render(hint), kind: entryToolResult, filePath: filePath, full: msg.content, line: startLine})
344351 }
345352 if wasBottom {
346353 m.scrollOffset = 0