Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 70 additions & 3 deletions src/lib/editorManager.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
import sidebarApps from "sidebarApps";

Check failure on line 1 in src/lib/editorManager.js

View workflow job for this annotation

GitHub Actions / Linting and formatting

assist/source/organizeImports

The imports and exports are not sorted.
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,
Expand All @@ -19,6 +26,8 @@
keymap,
lineNumbers,
placeholder,
drawSelection,
highlightActiveLine,
} from "@codemirror/view";
import {
abbreviationTracker,
Expand Down Expand Up @@ -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 {
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -1267,6 +1280,44 @@
return enabled ? tagAutoRename() : [];
},
},
{
keys: ["autoCloseBrackets", "bracketMatching"],
compartments: [bracketCompartment],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Unmanaged extensions remain

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, or highlightSelectionMatches off, 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.

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],

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Gutter highlight stays stale

This spec updates the main highlightActiveLine() extension, but the active-line gutter marker is configured through the line-number extension path. When highlightActiveLine is turned off, this listener only reconfigures highlightCompartment, so the gutter extension can keep using the old value and continue highlighting the active line in the gutter. The setting update needs to refresh both owners of active-line highlighting.

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],
Expand Down Expand Up @@ -3459,6 +3510,22 @@
applyOptions(["autoRenameTags"]);
});

appSettings.on("update:autoCloseBrackets", function () {
applyOptions(["autoCloseBrackets"]);
Comment thread
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"]);
});
Expand Down
Loading