Skip to content

Commit

Permalink
v2.5.7
Browse files Browse the repository at this point in the history
  • Loading branch information
thqby committed Dec 8, 2024
1 parent 35a55ed commit 9e59f6d
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 15 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "AutoHotkey v2 Language Support, based on vscode-lsp.",
"author": "thqby",
"publisher": "thqby",
"version": "2.5.6",
"version": "2.5.7",
"license": "LGPLv3.0",
"categories": [
"Formatters",
Expand Down
20 changes: 11 additions & 9 deletions server/src/Lexer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1640,7 +1640,7 @@ export class Lexer {
if (line_begin_pos !== undefined)
_this.linepos[(lk.pos ??= document.positionAt(lk.offset)).line] = line_begin_pos;
} else if (input[lk.offset + lk.length] === '(')
parse_call(lk, '(');
parse_call(lk, '('), result.push(...parse_line());
else {
reset_extra_index(tk), tk = lk, lk = EMPTY_TOKEN;
parser_pos = tk.offset + tk.length, next = true;
Expand Down Expand Up @@ -2811,10 +2811,8 @@ export class Lexer {
block_mode = false, incls && (mode = BlockType.Method);
loop:
while (nexttoken()) {
if (tk.topofline === 1) {
if (is_line_continue(lk, tk, _parent))
tk.topofline = -1;
else { next = false; break; }
if (tk.topofline === 1 && !is_line_continue(lk, tk, _parent)) {
next = false; break;
}
switch (tk.type) {
case 'TK_WORD':
Expand Down Expand Up @@ -2846,6 +2844,10 @@ export class Lexer {
vr.assigned ??= true, vr.decl = vr.def = true;
vr.range.end = document.positionAt(lk.offset + lk.length)
}
if (tk.content === ',') {
tk.topofline &&= -1;
continue;
}
} else {
if (incls) {
let llk = lk, ttk = tk, err = diagnostic.propnotinit(), dots = 0;
Expand Down Expand Up @@ -2957,7 +2959,7 @@ export class Lexer {
next = false;
break;
}
if (tk.type as string === 'TK_COMMA' || (tk.topofline && !is_line_continue(lk, tk, _parent))) {
if (tk.type as string === 'TK_COMMA' || tk.topofline && !is_line_continue(lk, tk, _parent)) {
const vr = addvariable(lk, md, sta);
if (vr) {
vr.decl = vr.def = true;
Expand All @@ -2967,8 +2969,8 @@ export class Lexer {
if (tk.type as string !== 'TK_COMMA') {
next = false;
break loop;
}
} else next = false, tk.topofline &&= -1;
} else tk.topofline &&= -1;
} else parse_expression(',', 0);
}
break;
case 'TK_COMMA':
Expand Down Expand Up @@ -7827,7 +7829,7 @@ export function get_callinfo(doc: Lexer, position: Position, pi?: ParamInfo) {
for (const c of pi.comma)
if (offset > c) ++index; else break;
kind ??= pi.method ? SymbolKind.Method : SymbolKind.Function;
return { name: pi.name ?? '', pos, index, kind };
return { name: pi.name ?? '', pos, index, kind, count: pi.count };
}
if (pi)
return get(pi);
Expand Down
19 changes: 14 additions & 5 deletions server/src/signatureProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ export async function signatureProvider(params: SignatureHelpParams, token: Canc
cache.loc = '';
return;
}
const { name, pos, index, kind } = res;
const { name, pos, index, kind, count } = res;
const loc = `${lex.uri}?${name},${pos.line},${pos.character}`;
if (loc === cache.loc) {
if (index === cache.index)
Expand Down Expand Up @@ -166,8 +166,8 @@ export async function signatureProvider(params: SignatureHelpParams, token: Canc
}
q += needthis > 0 ? 7 : 1, set.add(fn);
for (const f of fns) {
label = f.full, params = f.params;
activeParameter = f.variadic && params[(pc = params.length) - 1].arr ? Math.min(pi, pc - 1) : pi;
label = f.full, params = f.params, pc = params.length;
activeParameter = f.variadic && params[pc - 1].arr ? Math.min(pi, pc - 1) : pi;
name = params[activeParameter]?.name.toUpperCase() ?? (needthis && activeParameter === -1 ? 'this' : '\0');
param = fn.params.find(p => p.name.toUpperCase() === name) ?? fn.overload_params?.[name];
parameters = f.param_offsets.map((p, i) => ({ label: [p += q, p + (params![i]?.name.length || 1)] }));
Expand All @@ -176,8 +176,17 @@ export async function signatureProvider(params: SignatureHelpParams, token: Canc
label = label.replace(/(?<=.)\(/, '(this' + (params.length ? ', ' : ''));
}
if (param) {
if (param.arr === 2 && pi % 2 !== param.data)
activeParameter++;
if (param.arr === 2) {
const fi = pi % 2 !== param.data, fc = pc % 2 !== param.data, n = fc ? 2 : 1;
if ((!fi || ++activeParameter && fc) && index >= count - n)
if (index === count - 1 || activeParameter - n !== pc - 2)
activeParameter -= n;
param = params[activeParameter] ?? param;
} else if (index <= count - 2 && params.at(-1)?.arr === 2) {
const p = params.at(-1)!, fc = pc % 2 !== p.data, n = fc ? 2 : 1;
if (!params[activeParameter + n]?.name.length)
param = params[activeParameter += n] ?? p;
}
parameters[activeParameter].documentation = get_detail(param, lex);
}
signinfo.signatures.push({ label, parameters, documentation, activeParameter });
Expand Down

0 comments on commit 9e59f6d

Please sign in to comment.