Skip to content

Commit

Permalink
fix autocomplete offline sometimes
Browse files Browse the repository at this point in the history
  • Loading branch information
fonsp committed Dec 20, 2024
1 parent 42ef2b4 commit c13090a
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion frontend/components/CellInput/pluto_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -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?)
Expand Down Expand Up @@ -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)
}
}
})
}
Expand Down

0 comments on commit c13090a

Please sign in to comment.