Skip to content

Commit

Permalink
make local autocompletion go above other completions
Browse files Browse the repository at this point in the history
  • Loading branch information
Pangoraw committed Mar 20, 2022
1 parent e54b416 commit 66eee00
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions frontend/components/CellInput/pluto_autocomplete.js
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ const juliahints_cool_generator = (/** @type {PlutoRequestAutocomplete} */ reque
[`completion_${completion_type}`]: completion_type != null,
c_from_notebook: is_from_notebook,
}),
boost: 99 - i / results.length,
boost: 50 - i / results.length,
}
}),
// This is a small thing that I really want:
Expand Down Expand Up @@ -249,8 +249,11 @@ const local_variables_completion = (ctx) => {
from,
to,
options: scopestate.locals
.filter(({ validity, name }) => name.startsWith(text) && from > validity.from && to <= validity.to)
.map(({ name }) => ({ label: name })),
.filter(
({ validity, name }) =>
name.startsWith(text) /** <- NOTE: A smarter matching strategy can be used here */ && from > validity.from && to <= validity.to
)
.map(({ name }, i) => ({ label: name, type: "c_Any", boost: 99 - i })),
}
}

Expand Down Expand Up @@ -294,7 +297,6 @@ export let pluto_autocomplete = ({ request_autocomplete, on_update_doc_query })
override: [
unfiltered_julia_generator(memoize_last_request_autocomplete),
juliahints_cool_generator(memoize_last_request_autocomplete),
// TODO completion for local variables
local_variables_completion,
],
defaultKeymap: false, // We add these manually later, so we can override them if necessary
Expand Down

0 comments on commit 66eee00

Please sign in to comment.