mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-04-21 16:31:18 +02:00
Don't show unnamed variables in autocomplete
This commit is contained in:
@@ -1,35 +0,0 @@
|
|||||||
import { closeCompletion, startCompletion } from '@codemirror/autocomplete';
|
|
||||||
import { EditorView } from 'codemirror';
|
|
||||||
import { debounce } from '../../../lib/debounce';
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Debounce autocomplete until user stops typing for `millis` milliseconds.
|
|
||||||
*/
|
|
||||||
export function debouncedAutocompletionDisplay({ millis }: { millis: number }) {
|
|
||||||
// TODO: Figure out how to show completion without setting context.explicit = true
|
|
||||||
const debouncedStartCompletion = debounce(function (view: EditorView) {
|
|
||||||
startCompletion(view);
|
|
||||||
}, millis);
|
|
||||||
|
|
||||||
return EditorView.updateListener.of(({ view, docChanged }) => {
|
|
||||||
// const completions = currentCompletions(view.state);
|
|
||||||
// const status = completionStatus(view.state);
|
|
||||||
|
|
||||||
if (!view.hasFocus) {
|
|
||||||
debouncedStartCompletion.cancel();
|
|
||||||
closeCompletion(view);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (view.state.doc.length === 0) {
|
|
||||||
debouncedStartCompletion.cancel();
|
|
||||||
closeCompletion(view);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the document hasn't changed, we don't need to do anything
|
|
||||||
if (docChanged) {
|
|
||||||
debouncedStartCompletion(view);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
@@ -40,6 +40,7 @@ export function twigCompletion({ options }: TwigCompletionConfig) {
|
|||||||
validFor: () => true, // Not really sure why this is all it needs
|
validFor: () => true, // Not really sure why this is all it needs
|
||||||
from: toMatch.from,
|
from: toMatch.from,
|
||||||
options: options
|
options: options
|
||||||
|
.filter((v) => v.name.trim())
|
||||||
.map((v) => ({
|
.map((v) => ({
|
||||||
label: toStartOfVariable ? `${openTag}${v.name}${closeTag}` : v.name,
|
label: toStartOfVariable ? `${openTag}${v.name}${closeTag}` : v.name,
|
||||||
apply: `${openTag}${v.name}${closeTag}`,
|
apply: `${openTag}${v.name}${closeTag}`,
|
||||||
|
|||||||
Reference in New Issue
Block a user