Fix #37919 - don't show php suggestions when closing an html tag

This commit is contained in:
Rob Lourens 2017-11-28 21:41:53 -08:00
parent 6e90f8995d
commit ddb27c6312

View file

@ -5,12 +5,12 @@
'use strict'; 'use strict';
import { CompletionItemProvider, CompletionItem, CompletionItemKind, CancellationToken, TextDocument, Position, Range, TextEdit, workspace } from 'vscode'; import { CompletionItemProvider, CompletionItem, CompletionItemKind, CancellationToken, TextDocument, Position, Range, TextEdit, workspace, CompletionContext } from 'vscode';
import phpGlobals = require('./phpGlobals'); import phpGlobals = require('./phpGlobals');
export default class PHPCompletionItemProvider implements CompletionItemProvider { export default class PHPCompletionItemProvider implements CompletionItemProvider {
public provideCompletionItems(document: TextDocument, position: Position, _token: CancellationToken): Promise<CompletionItem[]> { public provideCompletionItems(document: TextDocument, position: Position, _token: CancellationToken, context: CompletionContext): Promise<CompletionItem[]> {
let result: CompletionItem[] = []; let result: CompletionItem[] = [];
let shouldProvideCompletionItems = workspace.getConfiguration('php').get<boolean>('suggest.basic', true); let shouldProvideCompletionItems = workspace.getConfiguration('php').get<boolean>('suggest.basic', true);
@ -24,6 +24,14 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider
range = new Range(position, position); range = new Range(position, position);
} }
if (context.triggerCharacter === '>') {
const twoBeforeCursor = new Position(position.line, Math.max(0, position.character - 2));
const previousTwoChars = document.getText(new Range(twoBeforeCursor, position));
if (previousTwoChars !== '->') {
return Promise.resolve(result);
}
}
var added: any = {}; var added: any = {};
var createNewProposal = function (kind: CompletionItemKind, name: string, entry: phpGlobals.IEntry | null): CompletionItem { var createNewProposal = function (kind: CompletionItemKind, name: string, entry: phpGlobals.IEntry | null): CompletionItem {
var proposal: CompletionItem = new CompletionItem(name); var proposal: CompletionItem = new CompletionItem(name);