Skip to content

Commit a089853

Browse files
committed
make standardBindings const
1 parent 6cb174b commit a089853

File tree

2 files changed

+18
-20
lines changed

2 files changed

+18
-20
lines changed

app/gui/src/project-view/components/CodeEditor/ensoSyntax.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ class EnsoParser extends Parser {
158158
}
159159
}
160160

161-
/** TODO: Add docs */
161+
/** CodeMirror extension that adds support for parsing enso language. */
162162
export function ensoSyntax(astRoot: Readonly<Ref<Ast.BodyBlock | undefined>>): Extension {
163163
return new LanguageSupport(new Language(facet, new EnsoParser(astRoot)), [indentUnit.of(' ')])
164164
}

app/gui/src/project-view/util/codemirror/index.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -318,29 +318,27 @@ const stopEvent = (event: Event) => {
318318
event.stopImmediatePropagation()
319319
return false
320320
}
321-
function bindStandardBindings(): Record<LineMode, KeyBinding[]> {
322-
const autoOrMultiHandlers = handlerToKeyBinding(
323-
textEditorsMultilineBindings.handler({
324-
newline: (e) => {
325-
e.stopImmediatePropagation()
326-
return insertNewlineKeepIndent(e.codemirrorView)
327-
},
328-
}),
329-
)
330-
return {
331-
single: [],
332-
multi: [autoOrMultiHandlers, ...verticalMovementKeymap()],
333-
auto: [autoOrMultiHandlers],
334-
}
321+
322+
const autoOrMultiHandlers = handlerToKeyBinding(
323+
textEditorsMultilineBindings.handler({
324+
newline: (e) => {
325+
e.stopImmediatePropagation()
326+
return insertNewlineKeepIndent(e.codemirrorView)
327+
},
328+
}),
329+
)
330+
331+
const standardBindings: Record<LineMode, KeyBinding[]> = {
332+
single: [],
333+
multi: [autoOrMultiHandlers, ...verticalMovementKeymap()],
334+
auto: [autoOrMultiHandlers],
335335
}
336336

337-
function keyBindings(lineMode: LineMode | undefined): Extension {
338-
const mode = lineMode ?? 'multi'
339-
const standardBindings = bindStandardBindings()
337+
function keyBindings(lineMode: LineMode): Extension {
340338
return [
341339
Prec.lowest(keymap.of(baseKeymap())),
342-
Prec.low(keymap.of(standardBindings[mode])),
343-
...(mode === 'multi' ? [EditorView.domEventHandlers({ wheel: stopEvent })] : []),
340+
Prec.low(keymap.of(standardBindings[lineMode])),
341+
...(lineMode === 'multi' ? [EditorView.domEventHandlers({ wheel: stopEvent })] : []),
344342
]
345343
}
346344

0 commit comments

Comments
 (0)