Skip to content

Commit

Permalink
Backport PR #15297 on branch 4.0.x (Fix autobrackets and other defaul…
Browse files Browse the repository at this point in the history
…t CM extension) (#15313)

* Backport PR #15297: Fix autobrackets and other default CM extension

* Remove highlightSpecialChars extension

---------

Co-authored-by: Frédéric Collonval <fcollonval@users.noreply.github.com>
  • Loading branch information
meeseeksmachine and fcollonval committed Oct 31, 2023
1 parent a5ef1ac commit 886eac3
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions packages/codemirror/src/extension.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright (c) Jupyter Development Team.
// Distributed under the terms of the Modified BSD License.

import { closeBrackets } from '@codemirror/autocomplete';
import { closeBrackets, closeBracketsKeymap } from '@codemirror/autocomplete';
import { defaultKeymap, indentLess } from '@codemirror/commands';
import {
bracketMatching,
Expand All @@ -13,6 +13,7 @@ import {
Compartment,
EditorState,
Extension,
Prec,
StateEffect
} from '@codemirror/state';
import {
Expand Down Expand Up @@ -715,7 +716,12 @@ export namespace EditorExtensionRegistry {
Object.freeze({
name: 'matchBrackets',
default: true,
factory: () => createConditionalExtension(bracketMatching()),
factory: () =>
createConditionalExtension([
bracketMatching(),
// closeBracketsKeymap must have higher precedence over defaultKeymap
Prec.high(keymap.of(closeBracketsKeymap))
]),
schema: {
type: 'boolean',
title: trans.__('Match Brackets')
Expand Down

0 comments on commit 886eac3

Please sign in to comment.