[add] initial handler stuff

This commit is contained in:
Andy Bunce 2025-09-07 22:04:53 +01:00
parent 7deb653208
commit 9533519b8a
10 changed files with 284 additions and 187 deletions

View file

@ -76,27 +76,7 @@ const baseExts = [
StreamLanguage.define(xQuery)
];
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);
}
});
};
// map cmd->{keybings,fn}
function listCommands(view) {
@ -114,4 +94,4 @@ function listCommands(view) {
export { baseExts, EditorView, EditorState, StateEffect, LSPPlugin, LSPClient,
openSearchPanel, openLintPanel, languageServerSupport, languageServerExtensions,
simpleWebSocketTransport, linter, formatDocument,keymap,formatKeymap, debouncedChangeListener, listCommands };
simpleWebSocketTransport, linter, formatDocument,keymap,formatKeymap, listCommands };