From c13090a053ea7725c3bf739a2f698f5dcccdf69a Mon Sep 17 00:00:00 2001 From: Fons van der Plas Date: Fri, 20 Dec 2024 15:52:21 +0100 Subject: [PATCH] fix autocomplete offline sometimes --- frontend/components/CellInput/pluto_autocomplete.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/frontend/components/CellInput/pluto_autocomplete.js b/frontend/components/CellInput/pluto_autocomplete.js index e48ab6fa2..fad1629ac 100644 --- a/frontend/components/CellInput/pluto_autocomplete.js +++ b/frontend/components/CellInput/pluto_autocomplete.js @@ -60,6 +60,8 @@ const pluto_autocomplete_keymap = [ * @param {(query: string) => void} on_update_doc_query */ let update_docs_from_autocomplete_selection = (on_update_doc_query) => { + let last_query = null + return EditorView.updateListener.of((update) => { // But we can use `selectedCompletion` to better check if the autocomplete is open // (for some reason `autocompletion_state?.open != null` isn't enough anymore?) @@ -100,7 +102,10 @@ let update_docs_from_autocomplete_selection = (on_update_doc_query) => { // So we can use `get_selected_doc_from_state` on our virtual state let docs_string = get_selected_doc_from_state(result_transaction.state) if (docs_string != null) { - on_update_doc_query(docs_string) + if (last_query != docs_string) { + last_query = docs_string + on_update_doc_query(docs_string) + } } }) }