@codemirror/lint
Advanced tools
Comparing version 6.2.2 to 6.3.0
@@ -0,1 +1,7 @@ | ||
## 6.3.0 (2023-06-23) | ||
### New features | ||
A new `previousDiagnostic` command can be used to move back through the active diagnostics. | ||
## 6.2.2 (2023-06-05) | ||
@@ -2,0 +8,0 @@ |
@@ -127,2 +127,6 @@ import * as _codemirror_state from '@codemirror/state'; | ||
/** | ||
Move the selection to the previous diagnostic. | ||
*/ | ||
declare const previousDiagnostic: Command; | ||
/** | ||
A set of default key bindings for the lint functionality. | ||
@@ -164,2 +168,2 @@ | ||
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect }; | ||
export { Action, Diagnostic, LintSource, closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect }; |
@@ -177,2 +177,26 @@ import { Decoration, showPanel, EditorView, ViewPlugin, logException, gutter, showTooltip, hoverTooltip, getPanel, WidgetType, GutterMarker } from '@codemirror/view'; | ||
/** | ||
Move the selection to the previous diagnostic. | ||
*/ | ||
const previousDiagnostic = (view) => { | ||
let { state } = view, field = state.field(lintState, false); | ||
if (!field) | ||
return false; | ||
let sel = state.selection.main; | ||
let prevFrom, prevTo, lastFrom, lastTo; | ||
field.diagnostics.between(0, state.doc.length, (from, to) => { | ||
if (to < sel.to && (prevFrom == null || prevFrom < from)) { | ||
prevFrom = from; | ||
prevTo = to; | ||
} | ||
if (lastFrom == null || from > lastFrom) { | ||
lastFrom = from; | ||
lastTo = to; | ||
} | ||
}); | ||
if (lastFrom == null || prevFrom == null && lastFrom == sel.from) | ||
return false; | ||
view.dispatch({ selection: { anchor: prevFrom !== null && prevFrom !== void 0 ? prevFrom : lastFrom, head: prevTo !== null && prevTo !== void 0 ? prevTo : lastTo }, scrollIntoView: true }); | ||
return true; | ||
}; | ||
/** | ||
A set of default key bindings for the lint functionality. | ||
@@ -759,2 +783,2 @@ | ||
export { closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics, setDiagnosticsEffect }; | ||
export { closeLintPanel, diagnosticCount, forEachDiagnostic, forceLinting, lintGutter, lintKeymap, linter, nextDiagnostic, openLintPanel, previousDiagnostic, setDiagnostics, setDiagnosticsEffect }; |
{ | ||
"name": "@codemirror/lint", | ||
"version": "6.2.2", | ||
"version": "6.3.0", | ||
"description": "Linting support for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
79076
1738