Skip to content

Commit

Permalink
fix(vision): fixes bug where codemirror would insert a new line on cm…
Browse files Browse the repository at this point in the history
…d-return (#6123)
  • Loading branch information
sgulseth authored Mar 26, 2024
1 parent 3822da2 commit 971ba9f
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions packages/@sanity/vision/src/codemirror/extensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
syntaxHighlighting,
} from '@codemirror/language'
import {highlightSelectionMatches} from '@codemirror/search'
import {Extension} from '@codemirror/state'
import {type Extension} from '@codemirror/state'
import {
drawSelection,
highlightActiveLine,
Expand All @@ -31,5 +31,16 @@ export const codemirrorExtensions: Extension[] = [
history(),
drawSelection(),
syntaxHighlighting(defaultHighlightStyle, {fallback: true}),
keymap.of([defaultKeymap, historyKeymap].flat().filter(Boolean)),
keymap.of(
[
// Override the default keymap for Mod-Enter to not insert a new line, we have a custom event handler for executing queries
{key: 'Mod-Enter', run: () => true},

// Add the default keymap and history keymap
defaultKeymap,
historyKeymap,
]
.flat()
.filter(Boolean),
),
]

0 comments on commit 971ba9f

Please sign in to comment.