Fix deadlock on getting the focused window

This commit is contained in:
Gregory Schier
2024-08-22 05:46:09 -07:00
parent 4c6684623f
commit 503b7f1c87
7 changed files with 37 additions and 30 deletions

View File

@@ -56,15 +56,14 @@ export function TemplateFunctionDialog({ templateFunction, hide, initialTokens,
}, []);
const tokens: Tokens = useMemo(() => {
console.log('HELLO', argValues);
const argTokens: FnArg[] = Object.keys(argValues).map((name) => ({
name,
value:
argValues[name] === NULL_ARG
? { type: 'null' }
: typeof argValues[name] === 'boolean'
? { type: 'bool', value: argValues[name] }
: { type: 'str', text: argValues[name] ?? '' },
? { type: 'bool', value: argValues[name] === true }
: { type: 'str', text: String(argValues[name] ?? '') },
}));
return {

View File

@@ -39,11 +39,12 @@ export function twig({
const functionOptions: TwigCompletionOption[] =
templateFunctions.map((fn) => {
const NUM_ARGS = 2;
const shortArgs =
fn.args
.slice(0, 1)
.slice(0, NUM_ARGS)
.map((a) => a.name)
.join(', ') + (fn.args.length > 1 ? ', …' : '');
.join(', ') + (fn.args.length > NUM_ARGS ? ', …' : '');
return {
name: fn.name,
type: 'function',

View File

@@ -37,7 +37,10 @@ class TemplateTagWidget extends WidgetType {
}`;
elt.title = this.option.invalid ? 'Not Found' : this.option.value ?? '';
elt.setAttribute('data-tag-type', this.option.type);
elt.textContent = this.option.label;
elt.textContent =
this.option.type === 'variable'
? this.option.name
: `${this.option.name}(${this.option.args.length ? '…' : ''})`;
elt.addEventListener('click', this.#clickListenerCallback);
return elt;
}