Skip to content

Commit

Permalink
Make sure we trigger js/ts completions on /
Browse files Browse the repository at this point in the history
  • Loading branch information
mjbvz committed Jun 19, 2018
1 parent 4d3a8ae commit f71c378
Showing 1 changed file with 27 additions and 25 deletions.
52 changes: 27 additions & 25 deletions extensions/typescript-language-features/src/features/completions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -449,42 +449,44 @@ class TypeScriptCompletionItemProvider implements vscode.CompletionItemProvider
line: vscode.TextLine,
position: vscode.Position
): boolean {
if ((context.triggerCharacter === '"' || context.triggerCharacter === '\'') && !this.client.apiVersion.gte(API.v290)) {
if (!config.quickSuggestionsForPaths) {
return false;
}
if (context.triggerCharacter && !this.client.apiVersion.gte(API.v290)) {
if ((context.triggerCharacter === '"' || context.triggerCharacter === '\'')) {
if (!config.quickSuggestionsForPaths) {
return false;
}

// make sure we are in something that looks like the start of an import
const pre = line.text.slice(0, position.character);
if (!pre.match(/\b(from|import)\s*["']$/) && !pre.match(/\b(import|require)\(['"]$/)) {
return false;
// make sure we are in something that looks like the start of an import
const pre = line.text.slice(0, position.character);
if (!pre.match(/\b(from|import)\s*["']$/) && !pre.match(/\b(import|require)\(['"]$/)) {
return false;
}
}
}

if (context.triggerCharacter === '/') {
if (!config.quickSuggestionsForPaths) {
return false;
if (context.triggerCharacter === '/') {
if (!config.quickSuggestionsForPaths) {
return false;
}

// make sure we are in something that looks like an import path
const pre = line.text.slice(0, position.character);
if (!pre.match(/\b(from|import)\s*["'][^'"]*$/) && !pre.match(/\b(import|require)\(['"][^'"]*$/)) {
return false;
}
}

// make sure we are in something that looks like an import path
const pre = line.text.slice(0, position.character);
if (!pre.match(/\b(from|import)\s*["'][^'"]*$/) && !pre.match(/\b(import|require)\(['"][^'"]*$/)) {
return false;
if (context.triggerCharacter === '@') {
// make sure we are in something that looks like the start of a jsdoc comment
const pre = line.text.slice(0, position.character);
if (!pre.match(/^\s*\*[ ]?@/) && !pre.match(/\/\*\*+[ ]?@/)) {
return false;
}
}
}

if (context.triggerCharacter === '@' && !this.client.apiVersion.gte(API.v290)) {
// make sure we are in something that looks like the start of a jsdoc comment
const pre = line.text.slice(0, position.character);
if (!pre.match(/^\s*\*[ ]?@/) && !pre.match(/\/\*\*+[ ]?@/)) {
if (context.triggerCharacter === '<') {
return false;
}
}

if (context.triggerCharacter === '<') {
return this.client.apiVersion.gte(API.v290);
}

return true;
}

Expand Down

0 comments on commit f71c378

Please sign in to comment.