Allow clicking to position cursor within current command

- Can now click anywhere in the current command line to edit
- Useful for editing commands from history
- Clicking before prompt automatically moves cursor to prompt position
- Prevents editing previous output
This commit is contained in:
2026-01-31 23:32:58 +00:00
parent bbff54b7a9
commit 9346719807
3 changed files with 9 additions and 0 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -355,6 +355,15 @@ class TerminalSession: NSObject, NSTextViewDelegate, NSMenuDelegate {
return result
}
func textViewDidChangeSelection(_ notification: Notification) {
// Allow cursor to be positioned anywhere in the current command
// But if user clicks before the prompt, move cursor to prompt position
let selectedRange = textView.selectedRange()
if selectedRange.location < promptPosition && selectedRange.length == 0 {
textView.setSelectedRange(NSRange(location: promptPosition, length: 0))
}
}
private func getCurrentCommand() -> String {
guard promptPosition <= textView.string.count else { return "" }
let startIndex = textView.string.index(textView.string.startIndex, offsetBy: promptPosition)