Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai a5cecb9b95 fix(plugins): keep document indexer markers on their lines while typing
Every edit emptied the indexed-marker gutter until the host re-indexed the
file. The column has no fixed width, so it collapsed and the text shifted
left, then back once the new markers arrived: typing in a mapped file made
the editor jitter. Map the markers through the change instead; a deleted
line still drops its own, and the next indexed result replaces them.
2026-11-14 23:26:41 +08:00
2 змінених файлів з 12 додано та 3 видалено

No files matched your search

+8 -1
Переглянути файл
@@ -56,10 +56,17 @@ it("puts a button on the marker's line that goes to its target", async () => {
expect(calls.navigate).toHaveBeenCalledWith(target);
});
it("hides markers on edit and when the entry goes away", async () => {
it("keeps markers on their lines while typing and hides them when the entry goes away", async () => {
setup();
await vi.waitFor(() => expect(button()).not.toBeNull());
// Typing must not empty the column: it would collapse and shift the text (#3370).
view!.dispatch({ changes: { from: source.indexOf("SELECT"), insert: "x" } });
expect(button()).not.toBeNull();
view!.dispatch({ changes: { from: 0, insert: "\n" } });
expect(button()).not.toBeNull();
// Deleting the marker's line drops it.
const line = view!.state.doc.line(3);
view!.dispatch({ changes: { from: line.from - 1, to: line.to } });
expect(button()).toBeNull();
usePluginMarkers.setState({ entries: new Map() });
await vi.waitFor(() => expect(button()).toBeNull());
+4 -2
Переглянути файл
@@ -1,7 +1,8 @@
/**
* Gutter markers from plugins' document indexers, resolved by the host from
* its cached graph. A click goes to the marker's targets (a chooser when there
* are several); an edit hides the markers until the edited text is indexed.
* are several); an edit keeps them on their lines until the edited text is indexed,
* so the column keeps its width while typing.
*/
import { RangeSet, StateEffect, StateField, type Extension } from "@codemirror/state";
import { EditorView, GutterMarker, ViewPlugin, gutter, type ViewUpdate } from "@codemirror/view";
@@ -52,7 +53,8 @@ const setMarkers = StateEffect.define<RangeSet<GutterMarker>>();
const markersField = StateField.define<RangeSet<GutterMarker>>({
create: () => RangeSet.empty,
update(value, tr) {
if (tr.docChanged) value = RangeSet.empty;
// Markers move with the text; a deleted line drops its own.
if (tr.docChanged) value = value.map(tr.changes);
for (const effect of tr.effects) if (effect.is(setMarkers)) value = effect.value;
return value;
},