Skip to content

Commit

Permalink
fix *CanAppendSemicolon*
Browse files Browse the repository at this point in the history
  • Loading branch information
Talv committed Apr 29, 2018
1 parent 97105a2 commit f01a63d
Showing 1 changed file with 18 additions and 7 deletions.
25 changes: 18 additions & 7 deletions src/service/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -346,17 +346,28 @@ export class CompletionsProvider extends AbstractProvider {
flags &= ~CompletionItemDataFlags.CanExpand;
}

if (position >= currentToken.end) {
flags |= CompletionItemDataFlags.CanAppendSemicolon;
}
else if (currentToken.parent) {
if (currentToken.parent) {
switch (currentToken.parent.kind) {
case gt.SyntaxKind.ExpressionStatement: {
flags |= currentToken.parent.syntaxTokens.findIndex(value => value.kind === gt.SyntaxKind.SemicolonToken) === -1 ? CompletionItemDataFlags.CanAppendSemicolon : 0;
if (position >= currentToken.end) {
flags |= CompletionItemDataFlags.CanAppendSemicolon;
}
else {
flags |= currentToken.parent.syntaxTokens.findIndex(value => value.kind === gt.SyntaxKind.SemicolonToken) === -1 ? CompletionItemDataFlags.CanAppendSemicolon : 0;
}
break;
}
case gt.SyntaxKind.Block:
case gt.SyntaxKind.SourceFile:
{
if (position >= currentToken.end) {
flags |= CompletionItemDataFlags.CanAppendSemicolon;
}
break;
}
case gt.SyntaxKind.Block: {
flags |= CompletionItemDataFlags.CanAppendSemicolon;
case gt.SyntaxKind.FunctionDeclaration:
{
flags &= ~CompletionItemDataFlags.CanExpand;
break;
}
}
Expand Down

0 comments on commit f01a63d

Please sign in to comment.