diff --git a/extensions/php/package.json b/extensions/php/package.json index 0d3134ffe95..6f235863bbc 100644 --- a/extensions/php/package.json +++ b/extensions/php/package.json @@ -44,6 +44,7 @@ } }, "scripts": { - "compile": "gulp compile-extension:php && gulp compile-extension:php" + "compile": "gulp compile-extension:php", + "watch": "gulp watch-extension:php" } } \ No newline at end of file diff --git a/extensions/php/src/features/completionItemProvider.ts b/extensions/php/src/features/completionItemProvider.ts index 6a8c8902c7f..7977b274aee 100644 --- a/extensions/php/src/features/completionItemProvider.ts +++ b/extensions/php/src/features/completionItemProvider.ts @@ -5,7 +5,7 @@ 'use strict'; -import {CompletionItemProvider, CompletionItem, CompletionItemKind, CancellationToken, TextDocument, Position} from 'vscode'; +import {CompletionItemProvider, CompletionItem, CompletionItemKind, CancellationToken, TextDocument, Position, Range, TextEdit} from 'vscode'; import phpGlobals = require('./phpGlobals'); export default class PHPCompletionItemProvider implements CompletionItemProvider { @@ -16,7 +16,10 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider let result: CompletionItem[] = []; var range = document.getWordRangeAtPosition(position); var prefix = range ? document.getText(range) : ''; - + if (!range) { + range = new Range(position, position); + } + var added : any = {}; var createNewProposal = function(kind: CompletionItemKind, name: string, entry: phpGlobals.IEntry) : CompletionItem { var proposal : CompletionItem = new CompletionItem(name); @@ -35,6 +38,18 @@ export default class PHPCompletionItemProvider implements CompletionItemProvider var matches = (name:string) => { return prefix.length === 0 || name.length >= prefix.length && name.substr(0, prefix.length) === prefix; }; + + if (matches('php') && range.start.character >= 2) { + let twoBeforePosition = new Position(range.start.line, range.start.character - 2); + let beforeWord = document.getText(new Range(twoBeforePosition, range.start)); + + if (beforeWord === '