@codemirror/lint
Advanced tools
Comparing version 0.18.4 to 0.18.5
@@ -0,1 +1,11 @@ | ||
## 0.18.5 (2021-08-07) | ||
### Bug fixes | ||
Fix an issue that caused `openLintPanel` to not actually open the panel when ran before the editor had any lint state loaded. | ||
### New features | ||
The package now exports a `forceLinting` function that forces pending lint queries to run immediately. | ||
## 0.18.4 (2021-06-07) | ||
@@ -2,0 +12,0 @@ |
@@ -90,3 +90,8 @@ import { EditorView, Command, KeyBinding } from '@codemirror/view'; | ||
}): Extension; | ||
/** | ||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the | ||
editor is idle to run right away. | ||
*/ | ||
declare function forceLinting(view: EditorView): void; | ||
export { Action, Diagnostic, closeLintPanel, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics }; | ||
export { Action, Diagnostic, closeLintPanel, forceLinting, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics }; |
@@ -45,5 +45,5 @@ import { EditorView, Decoration, ViewPlugin, logException, WidgetType } from '@codemirror/view'; | ||
} | ||
function maybeEnableLint(state, effects, diagnostics) { | ||
function maybeEnableLint(state, effects, getState) { | ||
return state.field(lintState, false) ? effects : effects.concat(StateEffect.appendConfig.of([ | ||
diagnostics ? lintState.init(() => LintState.init(diagnostics, null)) : lintState, | ||
lintState.init(getState), | ||
EditorView.decorations.compute([lintState], state => { | ||
@@ -65,3 +65,3 @@ let { selected, panel } = state.field(lintState); | ||
return { | ||
effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)], diagnostics) | ||
effects: maybeEnableLint(state, [setDiagnosticsEffect.of(diagnostics)], () => LintState.init(diagnostics, null)) | ||
}; | ||
@@ -130,3 +130,3 @@ } | ||
if (!field || !field.panel) | ||
view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel.of(true)]) }); | ||
view.dispatch({ effects: maybeEnableLint(view.state, [togglePanel.of(true)], () => LintState.init([], LintPanel.open)) }); | ||
let panel = getPanel(view, LintPanel.open); | ||
@@ -210,2 +210,8 @@ if (panel) | ||
} | ||
force() { | ||
if (this.set) { | ||
this.lintTime = Date.now(); | ||
this.run(); | ||
} | ||
} | ||
destroy() { | ||
@@ -230,2 +236,11 @@ clearTimeout(this.timeout); | ||
} | ||
/** | ||
Forces any linters [configured](https://codemirror.net/6/docs/ref/#lint.linter) to run when the | ||
editor is idle to run right away. | ||
*/ | ||
function forceLinting(view) { | ||
let plugin = view.plugin(lintPlugin); | ||
if (plugin) | ||
plugin.force(); | ||
} | ||
function assignKeys(actions) { | ||
@@ -546,2 +561,2 @@ let assigned = []; | ||
export { closeLintPanel, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics }; | ||
export { closeLintPanel, forceLinting, lintKeymap, linter, nextDiagnostic, openLintPanel, setDiagnostics }; |
{ | ||
"name": "@codemirror/lint", | ||
"version": "0.18.4", | ||
"version": "0.18.5", | ||
"description": "Linting support for the CodeMirror code editor", | ||
@@ -5,0 +5,0 @@ "scripts": { |
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
49729
1209