Skip to content

Commit bd8f2c2

Browse files
committed
fix(ls): trigger completions on '(', '[', and '*' for properties
fix: don't crash if completions asked on an unsupported file.
1 parent 3be775b commit bd8f2c2

File tree

2 files changed

+20
-18
lines changed

2 files changed

+20
-18
lines changed

server/src/errors.ts

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ export class ErrorCollector {
77
constructor(
88
private documents: TextDocuments,
99
private connection: IConnection,
10-
private initialDelay: number = 1500,
10+
private initialDelay: number = 750,
1111
private nextDelay: number = 20) {}
1212

1313
public requestErrors(...documents: TextDocumentIdentifier[]) {
@@ -28,23 +28,25 @@ export class ErrorCollector {
2828

2929
private sendErrorsFor(document: TextDocumentIdentifier) {
3030
const {fileName, service} = this.documents.getServiceInfo(document);
31-
const diagnostics = service.getDiagnostics(fileName);
32-
if (diagnostics) {
33-
const offsets = ([] as number[]).concat(...diagnostics.map(d => [d.span.start, d.span.end]));
34-
const positions = this.documents.offsetsToPositions(document, offsets);
35-
const ranges: Range[] = [];
36-
for (let i = 0; i < positions.length; i += 2) {
37-
ranges.push(Range.create(positions[i], positions[i+1]));
31+
if (service) {
32+
const diagnostics = service.getDiagnostics(fileName);
33+
if (diagnostics) {
34+
const offsets = ([] as number[]).concat(...diagnostics.map(d => [d.span.start, d.span.end]));
35+
const positions = this.documents.offsetsToPositions(document, offsets);
36+
const ranges: Range[] = [];
37+
for (let i = 0; i < positions.length; i += 2) {
38+
ranges.push(Range.create(positions[i], positions[i+1]));
39+
}
40+
this.connection.sendDiagnostics({
41+
uri: document.uri,
42+
diagnostics: diagnostics.map((diagnostic, i) => ({
43+
range: ranges[i],
44+
message: diagnostic.message,
45+
severity: DiagnosticSeverity.Error,
46+
source: 'Angular'
47+
}))
48+
});
3849
}
39-
this.connection.sendDiagnostics({
40-
uri: document.uri,
41-
diagnostics: diagnostics.map((diagnostic, i) => ({
42-
range: ranges[i],
43-
message: diagnostic.message,
44-
severity: DiagnosticSeverity.Error,
45-
source: 'Angular'
46-
}))
47-
});
4850
}
4951
}
5052
}

server/src/server.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ connection.onInitialize((params): InitializeResult => {
5656
// Tell the client that the server support code complete
5757
completionProvider: {
5858
resolveProvider: false,
59-
triggerCharacters: ['<', '.']
59+
triggerCharacters: ['<', '.', '*', '[', '(']
6060
}
6161
}
6262
}

0 commit comments

Comments
 (0)