File tree Expand file tree Collapse file tree 2 files changed +9
-16
lines changed
Example/CodeEditSourceEditorExample/CodeEditSourceEditorExample/Views
Sources/CodeEditSourceEditor/Controller Expand file tree Collapse file tree 2 files changed +9
-16
lines changed Original file line number Diff line number Diff line change @@ -21,7 +21,7 @@ struct ContentView: View {
2121 @State private var theme : EditorTheme = . light
2222 @State private var font : NSFont = NSFont . monospacedSystemFont ( ofSize: 12 , weight: . medium)
2323 @AppStorage ( " wrapLines " ) private var wrapLines : Bool = true
24- @State private var cursorPositions : [ CursorPosition ] = [ ]
24+ @State private var cursorPositions : [ CursorPosition ] = [ . init ( line : 1 , column : 1 ) ]
2525 @AppStorage ( " systemCursor " ) private var useSystemCursor : Bool = false
2626 @State private var isInLongParse = false
2727 @State private var treeSitterClient = TreeSitterClient ( )
Original file line number Diff line number Diff line change @@ -129,21 +129,7 @@ extension TextViewController {
129129 eventMonitor = NSEvent . addLocalMonitorForEvents ( matching: . keyDown) { [ weak self] event -> NSEvent ? in
130130 guard self ? . view. window? . firstResponder == self ? . textView else { return event }
131131 let modifierFlags = event. modifierFlags. intersection ( . deviceIndependentFlagsMask)
132-
133- switch ( modifierFlags, event. charactersIgnoringModifiers? . lowercased ( ) ) {
134- case ( . command, " / " ) :
135- self ? . handleCommandSlash ( )
136- return nil
137- case ( . command, " f " ) :
138- _ = self ? . textView. resignFirstResponder ( )
139- self ? . searchController? . showFindPanel ( )
140- return nil
141- case ( [ ] , " \u{1b} " ) : // Escape key
142- self ? . searchController? . findPanel. cancel ( )
143- return nil
144- default :
145- return event
146- }
132+ return self ? . handleCommand ( event: event, modifierFlags: modifierFlags. rawValue)
147133 }
148134 }
149135
@@ -160,6 +146,13 @@ extension TextViewController {
160146 case ( commandKey, " ] " ) :
161147 handleIndent ( )
162148 return nil
149+ case ( commandKey, " f " ) :
150+ _ = self . textView. resignFirstResponder ( )
151+ self . searchController? . showFindPanel ( )
152+ return nil
153+ case ( 0 , " \u{1b} " ) : // Escape key
154+ self . searchController? . findPanel. cancel ( )
155+ return nil
163156 case ( _, _) :
164157 return event
165158 }
You can’t perform that action at this time.
0 commit comments