diff --git a/.DS_Store b/.DS_Store index 118664e..6f0edab 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/EnhancedTerminal.app/Contents/MacOS/EnhancedTerminal b/EnhancedTerminal.app/Contents/MacOS/EnhancedTerminal index 2c804a5..54d24fc 100755 Binary files a/EnhancedTerminal.app/Contents/MacOS/EnhancedTerminal and b/EnhancedTerminal.app/Contents/MacOS/EnhancedTerminal differ diff --git a/TerminalSession.swift b/TerminalSession.swift index 48f1b8f..48cca60 100644 --- a/TerminalSession.swift +++ b/TerminalSession.swift @@ -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)