Skip to content

Commit

Permalink
Be less aggressive about snippet completion triggers (#798)
Browse files Browse the repository at this point in the history
* Be less agressive about snippet completion triggers

* PR fix
  • Loading branch information
StephenWeatherford authored Jun 18, 2020
1 parent b5147cf commit c4c0b19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/PositionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export interface IReferenceSite {
}

/**
* Represents a position inside the snapshot of a deployment parameter file, plus all related information
* (Abstract base class) Represents a position inside the snapshot of a deployment file, plus all related information
* that can be parsed and analyzed about it from that position.
*/
export abstract class PositionContext {
Expand Down
15 changes: 11 additions & 4 deletions src/TemplatePositionContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -189,10 +189,17 @@ export class TemplatePositionContext extends PositionContext {

return [];
} else {
// No string at this location, so we ask the snippet manager
// for valid snippet completions
let replacementSpan = this.getJsonReplacementSpan() ?? this.emptySpanAtDocumentCharacterIndex;
return await ext.snippetManager.value.getSnippetsAsCompletionItems(replacementSpan, triggerCharacter);
// No string at this location, so it might be a good place for snippet completions

// Until we add more context intelligence, just bring up snippets on the space
// character or when manually triggered by the user
if (triggerCharacter === ' ' || triggerCharacter === undefined) {
// Show snippets
let replacementSpan = this.getJsonReplacementSpan() ?? this.emptySpanAtDocumentCharacterIndex;
return await ext.snippetManager.value.getSnippetsAsCompletionItems(replacementSpan, triggerCharacter);
}

return [];
}
}

Expand Down

0 comments on commit c4c0b19

Please sign in to comment.