mirror of
https://github.com/mountain-loop/yaak.git
synced 2026-03-25 02:41:21 +01:00
Autocomplete URLs of other requests
This commit is contained in:
@@ -17,9 +17,12 @@ export interface GenericCompletionConfig {
|
||||
options: GenericCompletionOption[];
|
||||
}
|
||||
|
||||
/**
|
||||
* Complete options, always matching until the start of the line
|
||||
*/
|
||||
export function genericCompletion({ options, minMatch = 1 }: GenericCompletionConfig) {
|
||||
return function completions(context: CompletionContext) {
|
||||
const toMatch = context.matchBefore(/\w*/);
|
||||
const toMatch = context.matchBefore(/.*/);
|
||||
|
||||
// Only match if we're at the start of the line
|
||||
if (toMatch === null || toMatch.from > 0) return null;
|
||||
|
||||
@@ -21,20 +21,12 @@ export function twig(
|
||||
const completions = twigCompletion({ options: variables });
|
||||
|
||||
const language = mixLanguage(base);
|
||||
const completion = language.data.of({ autocomplete: completions });
|
||||
const completionBase = base.language.data.of({ autocomplete: completions });
|
||||
const additionalCompletion = autocomplete
|
||||
? [language.data.of({ autocomplete: genericCompletion(autocomplete) })]
|
||||
? [base.language.data.of({ autocomplete: genericCompletion(autocomplete) })]
|
||||
: [];
|
||||
|
||||
return [
|
||||
language,
|
||||
completion,
|
||||
completionBase,
|
||||
base.support,
|
||||
placeholders(variables),
|
||||
...additionalCompletion,
|
||||
];
|
||||
return [language, completionBase, base.support, placeholders(variables), ...additionalCompletion];
|
||||
}
|
||||
|
||||
function mixLanguage(base: LanguageSupport): LRLanguage {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { LanguageSupport, LRLanguage } from '@codemirror/language';
|
||||
import { completions } from './completion';
|
||||
import { parser } from './url';
|
||||
|
||||
const urlLanguage = LRLanguage.define({
|
||||
@@ -7,8 +6,6 @@ const urlLanguage = LRLanguage.define({
|
||||
languageData: {},
|
||||
});
|
||||
|
||||
const completion = urlLanguage.data.of({ autocomplete: completions });
|
||||
|
||||
export function url() {
|
||||
return new LanguageSupport(urlLanguage, [completion]);
|
||||
return new LanguageSupport(urlLanguage, []);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user