Unified completions into a function, small snippet improvement

This commit is contained in:
Alexandros Naskos
2020-05-13 20:30:57 +03:00
parent 20afe9ef3c
commit 0e0789b2d5
2 changed files with 57 additions and 74 deletions

View File

@@ -115,8 +115,13 @@ pub fn getFunctionSnippet(allocator: *std.mem.Allocator, tree: *ast.Tree, func:
var curr_tok = param_decl.type_node.firstToken();
var end_tok = param_decl.type_node.lastToken();
while (curr_tok <= end_tok) : (curr_tok += 1) {
const id = tree.tokens.at(curr_tok).id;
const is_comma = tree.tokens.at(curr_tok).id == .Comma;
if (curr_tok == end_tok and is_comma) continue;
try buffer.appendSlice(tree.tokenSlice(curr_tok));
if (tree.tokens.at(curr_tok).id == .Comma) try buffer.append(' ');
if (is_comma or id == .Keyword_const) try buffer.append(' ');
}
try buffer.append('}');