[mod] idle detect
This commit is contained in:
parent
e32e3437a1
commit
1787a8e31f
7 changed files with 2016 additions and 1964 deletions
|
|
@ -5,7 +5,7 @@ import { indentWithTab, history, defaultKeymap, historyKeymap } from '@codemirro
|
|||
import { foldGutter, indentOnInput, indentUnit, bracketMatching, foldKeymap, syntaxHighlighting, defaultHighlightStyle } from '@codemirror/language';
|
||||
import { closeBrackets, autocompletion, closeBracketsKeymap, completionKeymap } from '@codemirror/autocomplete';
|
||||
import { lineNumbers, highlightActiveLineGutter, highlightSpecialChars, drawSelection, dropCursor, rectangularSelection, crosshairCursor, highlightActiveLine, keymap, EditorView } from '@codemirror/view';
|
||||
import { markdown } from "@codemirror/lang-markdown";
|
||||
|
||||
// Theme
|
||||
import { oneDark } from "@codemirror/theme-one-dark";
|
||||
import { LSPClient, LSPPlugin, languageServerSupport } from "@codemirror/lsp-client";
|
||||
|
|
@ -76,10 +76,32 @@ function createEditorState(initialContents, extensions, options = {}) {
|
|||
function createEditorView(state, parent) {
|
||||
return new EditorView({ state, parent });
|
||||
}
|
||||
|
||||
class xqLinter {
|
||||
constructor(parameters) {
|
||||
this.fred = parameters;
|
||||
}
|
||||
}
|
||||
|
||||
export { createEditorState, createEditorView, openSearchPanel, openLintPanel, languageServerSupport, baseExts, simpleWebSocketTransport, linter, LSPPlugin, setDiagnostics, xqLinter, LSPClient };
|
||||
function debouncedChangeListener({ delay = 750, onChange }) {
|
||||
let timeoutId = null;
|
||||
let lastContent = '';
|
||||
|
||||
return EditorView.updateListener.of(update => {
|
||||
if (update.docChanged) {
|
||||
const currentContent = update.state.doc.toString();
|
||||
|
||||
if (timeoutId) {
|
||||
clearTimeout(timeoutId);
|
||||
}
|
||||
|
||||
timeoutId = setTimeout(() => {
|
||||
if (currentContent !== lastContent) {
|
||||
lastContent = currentContent;
|
||||
onChange(currentContent, update.state);
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export { createEditorState, createEditorView, openSearchPanel, openLintPanel, languageServerSupport, baseExts, simpleWebSocketTransport, linter, LSPPlugin, setDiagnostics, xqLinter, LSPClient,debouncedChangeListener };
|
||||
Loading…
Add table
Add a link
Reference in a new issue