@codemirror/lint 6.2.2 → 6.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/dist/index.cjs +25 -0
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.js +25 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
package/dist/index.cjs
CHANGED
|
@@ -182,6 +182,30 @@ const nextDiagnostic = (view) => {
|
|
|
182
182
|
return true;
|
|
183
183
|
};
|
|
184
184
|
/**
|
|
185
|
+
Move the selection to the previous diagnostic.
|
|
186
|
+
*/
|
|
187
|
+
const previousDiagnostic = (view) => {
|
|
188
|
+
let { state } = view, field = state.field(lintState, false);
|
|
189
|
+
if (!field)
|
|
190
|
+
return false;
|
|
191
|
+
let sel = state.selection.main;
|
|
192
|
+
let prevFrom, prevTo, lastFrom, lastTo;
|
|
193
|
+
field.diagnostics.between(0, state.doc.length, (from, to) => {
|
|
194
|
+
if (to < sel.to && (prevFrom == null || prevFrom < from)) {
|
|
195
|
+
prevFrom = from;
|
|
196
|
+
prevTo = to;
|
|
197
|
+
}
|
|
198
|
+
if (lastFrom == null || from > lastFrom) {
|
|
199
|
+
lastFrom = from;
|
|
200
|
+
lastTo = to;
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
if (lastFrom == null || prevFrom == null && lastFrom == sel.from)
|
|
204
|
+
return false;
|
|
205
|
+
view.dispatch({ selection: { anchor: prevFrom !== null && prevFrom !== void 0 ? prevFrom : lastFrom, head: prevTo !== null && prevTo !== void 0 ? prevTo : lastTo }, scrollIntoView: true });
|
|
206
|
+
return true;
|
|
207
|
+
};
|
|
208
|
+
/**
|
|
185
209
|
A set of default key bindings for the lint functionality.
|
|
186
210
|
|
|
187
211
|
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
|
@@ -772,5 +796,6 @@ exports.lintKeymap = lintKeymap;
|
|
|
772
796
|
exports.linter = linter;
|
|
773
797
|
exports.nextDiagnostic = nextDiagnostic;
|
|
774
798
|
exports.openLintPanel = openLintPanel;
|
|
799
|
+
exports.previousDiagnostic = previousDiagnostic;
|
|
775
800
|
exports.setDiagnostics = setDiagnostics;
|
|
776
801
|
exports.setDiagnosticsEffect = setDiagnosticsEffect;
|
package/dist/index.d.cts
CHANGED
|
@@ -124,6 +124,10 @@ Move the selection to the next diagnostic.
|
|
|
124
124
|
*/
|
|
125
125
|
declare const nextDiagnostic: Command;
|
|
126
126
|
/**
|
|
127
|
+
Move the selection to the previous diagnostic.
|
|
128
|
+
*/
|
|
129
|
+
declare const previousDiagnostic: Command;
|
|
130
|
+
/**
|
|
127
131
|
A set of default key bindings for the lint functionality.
|
|
128
132
|
|
|
129
133
|
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
|
@@ -160,4 +164,4 @@ arguments hold the diagnostic's current position.
|
|
|
160
164
|
*/
|
|
161
165
|
declare function forEachDiagnostic(state: EditorState, f: (d: Diagnostic, from: number, to: number) => void): void;
|
|
162
166
|
|
|
163
|
-
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect };
|
|
167
|
+
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
|
package/dist/index.d.ts
CHANGED
|
@@ -124,6 +124,10 @@ Move the selection to the next diagnostic.
|
|
|
124
124
|
*/
|
|
125
125
|
declare const nextDiagnostic: Command;
|
|
126
126
|
/**
|
|
127
|
+
Move the selection to the previous diagnostic.
|
|
128
|
+
*/
|
|
129
|
+
declare const previousDiagnostic: Command;
|
|
130
|
+
/**
|
|
127
131
|
A set of default key bindings for the lint functionality.
|
|
128
132
|
|
|
129
133
|
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
|
@@ -160,4 +164,4 @@ arguments hold the diagnostic's current position.
|
|
|
160
164
|
*/
|
|
161
165
|
declare function forEachDiagnostic(state: EditorState, f: (d: Diagnostic, from: number, to: number) => void): void;
|
|
162
166
|
|
|
163
|
-
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect };
|
|
167
|
+
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
|
package/dist/index.js
CHANGED
|
@@ -174,6 +174,30 @@ const nextDiagnostic = (view) => {
|
|
|
174
174
|
return true;
|
|
175
175
|
};
|
|
176
176
|
/**
|
|
177
|
+
Move the selection to the previous diagnostic.
|
|
178
|
+
*/
|
|
179
|
+
const previousDiagnostic = (view) => {
|
|
180
|
+
let { state } = view, field = state.field(lintState, false);
|
|
181
|
+
if (!field)
|
|
182
|
+
return false;
|
|
183
|
+
let sel = state.selection.main;
|
|
184
|
+
let prevFrom, prevTo, lastFrom, lastTo;
|
|
185
|
+
field.diagnostics.between(0, state.doc.length, (from, to) => {
|
|
186
|
+
if (to < sel.to && (prevFrom == null || prevFrom < from)) {
|
|
187
|
+
prevFrom = from;
|
|
188
|
+
prevTo = to;
|
|
189
|
+
}
|
|
190
|
+
if (lastFrom == null || from > lastFrom) {
|
|
191
|
+
lastFrom = from;
|
|
192
|
+
lastTo = to;
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
if (lastFrom == null || prevFrom == null && lastFrom == sel.from)
|
|
196
|
+
return false;
|
|
197
|
+
view.dispatch({ selection: { anchor: prevFrom !== null && prevFrom !== void 0 ? prevFrom : lastFrom, head: prevTo !== null && prevTo !== void 0 ? prevTo : lastTo }, scrollIntoView: true });
|
|
198
|
+
return true;
|
|
199
|
+
};
|
|
200
|
+
/**
|
|
177
201
|
A set of default key bindings for the lint functionality.
|
|
178
202
|
|
|
179
203
|
- Ctrl-Shift-m (Cmd-Shift-m on macOS): [`openLintPanel`](https://codemirror.net/6/docs/ref/#lint.openLintPanel)
|
|
@@ -755,4 +779,4 @@ function forEachDiagnostic(state, f) {
|
|
|
755
779
|
f(iter.value.spec.diagnostic, iter.from, iter.to);
|
|
756
780
|
}
|
|
757
781
|
|
|
758
|
-
export { closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect };
|
|
782
|
+
export { closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect };
|