Skip to content

Commit

Permalink
Use more natural alternates for code folding on Macs.
Browse files Browse the repository at this point in the history
The CodeMirror defaults don't make sense.
  • Loading branch information
drgrice1 committed Oct 7, 2024
1 parent 1a5764f commit c202afa
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/pg-codemirror-editor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,17 @@ import {
toggleLineComment,
toggleBlockCommentByLine
} from '@codemirror/commands';
import { bracketMatching, foldGutter, foldKeymap, indentOnInput, indentUnit, syntaxTree } from '@codemirror/language';
import {
bracketMatching,
foldGutter,
foldCode,
unfoldCode,
foldAll,
unfoldAll,
indentOnInput,
indentUnit,
syntaxTree
} from '@codemirror/language';
import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete';
import { highlightSelectionMatches, searchKeymap } from '@codemirror/search';
import type { SyntaxNode } from '@lezer/common';
Expand Down Expand Up @@ -124,7 +134,10 @@ export class View {
...defaultKeymap.filter((k) => k.key !== 'Mod-Enter'),
...searchKeymap,
...historyKeymap,
...foldKeymap,
{ key: 'Ctrl-Shift-[', mac: 'Cmd-Shift-[', run: foldCode },
{ key: 'Ctrl-Shift-]', mac: 'Cmd-Shift-]', run: unfoldCode },
{ key: 'Ctrl-Alt-[', mac: 'Cmd-Alt-[', run: foldAll },
{ key: 'Ctrl-Alt-]', mac: 'Cmd-Alt-]', run: unfoldAll },
...completionKeymap,
indentWithTab
]),
Expand Down

0 comments on commit c202afa

Please sign in to comment.