-
Notifications
You must be signed in to change notification settings - Fork 1.6k
fix: Add missing listener for autoCloseBrackets setting #2471
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,13 @@ | ||
| import sidebarApps from "sidebarApps"; | ||
| import { indentUnit, language as languageFacet } from "@codemirror/language"; | ||
| import { search } from "@codemirror/search"; | ||
| import { | ||
| indentUnit, | ||
| language as languageFacet, | ||
| bracketMatching, | ||
| foldGutter, | ||
| indentOnInput, | ||
| syntaxHighlighting, | ||
| } from "@codemirror/language"; | ||
| import { highlightSelectionMatches, search } from "@codemirror/search"; | ||
| import { | ||
| Compartment, | ||
| EditorSelection, | ||
|
|
@@ -19,6 +26,8 @@ | |
| keymap, | ||
| lineNumbers, | ||
| placeholder, | ||
| drawSelection, | ||
| highlightActiveLine, | ||
| } from "@codemirror/view"; | ||
| import { | ||
| abbreviationTracker, | ||
|
|
@@ -62,7 +71,7 @@ | |
| } from "cm/modelist"; | ||
| import createTouchSelectionMenu from "cm/touchSelectionMenu"; | ||
| import "cm/supportedModes"; | ||
| import { autocompletion } from "@codemirror/autocomplete"; | ||
| import { autocompletion, closeBrackets } from "@codemirror/autocomplete"; | ||
| import { serverCompletionSource } from "@codemirror/lsp-client"; | ||
| import colorView from "cm/colorView"; | ||
| import { | ||
|
|
@@ -937,6 +946,10 @@ | |
| const tagAutoRenameCompartment = new Compartment(); | ||
| // Compartment for read-only toggling | ||
| const readOnlyCompartment = new Compartment(); | ||
| // Compartment for brackets | ||
| const bracketCompartment = new Compartment(); | ||
| // Compartment for highlight | ||
| const highlightCompartment = new Compartment(); | ||
| // Compartment for scrolling past the end of the file | ||
| const scrollPastEndCompartment = new Compartment(); | ||
| // Compartment for language mode (allows async loading/reconfigure) | ||
|
|
@@ -1267,6 +1280,44 @@ | |
| return enabled ? tagAutoRename() : []; | ||
| }, | ||
| }, | ||
| { | ||
| keys: ["autoCloseBrackets", "bracketMatching"], | ||
| compartments: [bracketCompartment], | ||
| build() { | ||
| const ext = []; | ||
|
|
||
| if (appSettings.value.autoCloseBrackets !== false) { | ||
| ext.push(closeBrackets()); | ||
| } | ||
|
|
||
| if (appSettings.value.bracketMatching !== false) { | ||
| ext.push(bracketMatching()); | ||
| } | ||
|
|
||
| return ext; | ||
| }, | ||
| }, | ||
| { | ||
| keys: ["highlightActiveLine", "highlightSelectionMatches"], | ||
| compartments: [highlightCompartment], | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This spec updates the main |
||
| build() { | ||
| const ext = []; | ||
|
|
||
| if (appSettings.value.highlightActiveLine !== false) { | ||
| ext.push(highlightActiveLine()); | ||
| } | ||
|
|
||
| if (appSettings.value.highlightSelectionMatches !== false) { | ||
| ext.push( | ||
| highlightSelectionMatches({ | ||
| minSelectionLength: 1, | ||
| }), | ||
| ); | ||
| } | ||
|
|
||
| return ext; | ||
| }, | ||
| }, | ||
| { | ||
| keys: ["scrollPastEnd"], | ||
| compartments: [scrollPastEndCompartment], | ||
|
|
@@ -3459,6 +3510,22 @@ | |
| applyOptions(["autoRenameTags"]); | ||
| }); | ||
|
|
||
| appSettings.on("update:autoCloseBrackets", function () { | ||
| applyOptions(["autoCloseBrackets"]); | ||
|
greptile-apps[bot] marked this conversation as resolved.
|
||
| }); | ||
|
|
||
| appSettings.on("update:bracketMatching", function () { | ||
| applyOptions(["bracketMatching"]); | ||
| }); | ||
|
|
||
| appSettings.on("update:highlightActiveLine", function () { | ||
| applyOptions(["highlightActiveLine"]); | ||
| }); | ||
|
|
||
| appSettings.on("update:highlightSelectionMatches", function () { | ||
| applyOptions(["highlightSelectionMatches"]); | ||
| }); | ||
|
|
||
| appSettings.on("update:scrollPastEnd", function () { | ||
| applyOptions(["scrollPastEnd"]); | ||
| }); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This dynamic option now owns the compartmented bracket extensions, but editor states still get the same bracket and highlight extensions from the static base extension path. When a user turns
autoCloseBrackets,bracketMatching,highlightActiveLine, orhighlightSelectionMatchesoff,applyOptions()can remove only the compartmented copy. The unmanaged copy remains active in the editor state, so the setting can still appear changed while the editor keeps the old bracket or highlight behavior. These extensions need a single owner so runtime setting changes can fully remove them.