Skip to content

Commit

Permalink
fix #31
Browse files Browse the repository at this point in the history
  • Loading branch information
mackenza committed May 9, 2015
1 parent 35b555d commit 8d5c2e2
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
# Change Log
All notable changes to this project will be documented in this file.

## 1.1.7 - 2015-05-09

### Added
- Fix for [issue #31](https://github.com/mackenza/Brackets-PHP-SmartHints/issues/31)

## 1.1.6 - 2015-03-11

### Added
Expand Down
7 changes: 4 additions & 3 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ define(function (require, exports, module) {
*/
function PHPHints() {
this.activeToken = "";
this.lastToken = "";
this.cachedPhpVariables = [];
this.cachedPhpConstants = [];
this.cachedPhpKeywords = [];
this.cachedPhpFunctions = [];
this.cachedLocalVariables = [];
this.tokenVariable = /[$][\a-zA-Z_][a-zA-Z0-9_]*/g;
this.newUserVarSession = false;
}

PHPHints.prototype.hasHints = function (editor, implicitChar) {
Expand All @@ -74,6 +74,7 @@ define(function (require, exports, module) {

// if implicitChar or 1 letter token is $, we *always* have hints so return immediately
if (implicitChar === "$" || this.activeToken.token.string.charAt(0) === "$") {
this.newUserVarSession = true;
return true;
}

Expand Down Expand Up @@ -120,7 +121,7 @@ define(function (require, exports, module) {
tokenToCursor = getTokenToCursor(this.activeToken);
// if it's a $variable, then build the local variable list
if (implicitChar === "$" || this.activeToken.token.string.charAt(0) === "$") {
if ((this.lastToken === "") || (this.activeToken.token.start !== this.lastToken.token.start) || (this.activeToken.pos.line !== this.lastToken.pos.line)) {
if (this.newUserVarSession) {
this.cachedLocalVariables.length = 0;
var varList = this.editor.document.getText().match(this.tokenVariable);
if (varList) {
Expand All @@ -132,7 +133,7 @@ define(function (require, exports, module) {
}
}
}
this.lastToken = this.activeToken;
this.newUserVarSession = false;

if (this.cachedLocalVariables === null) {
return null;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"title": "PHP SmartHints",
"description": "Provides code hints for PHP files including PHP keywords, built-in functions, constants and variables. Also provides hinting for variables in the current open PHP document. Note that this is a continuation of the former [PHP-SIG] Brackets-PHP-SmartHints and not a new extension or fork. The Brackets Registry flags it as a new extension if you change the name (makes sense).",
"homepage": "https://github.com/mackenza/Brackets-PHP-SmartHints",
"version": "1.1.6",
"version": "1.1.7",
"author": "Andrew MacKenzie <a.mackenzie@gmail.com> (https://github.com/mackenza)",
"license": "MIT",
"engines": {
Expand Down

0 comments on commit 8d5c2e2

Please sign in to comment.