From 211452c9a9d6f88504a540f23b1aaba197df899e Mon Sep 17 00:00:00 2001 From: Thomas Wilburn Date: Thu, 17 Oct 2013 15:39:54 -0700 Subject: [PATCH] Add a special reference test for JavaScript, which gets all the syntax love. Also fix a bug where results were reordered when the "current" tab changed. --- js/palette.js | 9 ++++++--- manifest.json | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/js/palette.js b/js/palette.js index 829ef4c..d289824 100644 --- a/js/palette.js +++ b/js/palette.js @@ -9,6 +9,7 @@ define([ var TokenIterator = ace.require("ace/token_iterator").TokenIterator; var refTest = /identifier|variable|function/; + var jsRefTest = /entity\.name\.function/; var resultTemplate = document.find("#palette-result").content; var sanitize = function(text) { @@ -37,6 +38,7 @@ define([ var template = "
%LABEL%
%SUB%
" var Palette = function() { + this.homeTab = null; this.results = []; this.cache = {}; this.selected = 0; @@ -139,7 +141,7 @@ define([ var ti = new TokenIterator(tab, 0); var token; while (token = ti.stepForward()) { - if (refTest.test(token.type)) { + if (tab.syntaxMode == "javascript" ? jsRefTest.test(token.type) : refTest.test(token.type)) { //this is a match, let's store it as a valid result object var row = ti.getCurrentTokenRow(); var col = ti.getCurrentTokenColumn(); @@ -178,7 +180,7 @@ define([ return fuzzyFile.test(tab.fileName); }); } else { - var current = sessions.getCurrent(); + var current = this.homeTab; tabs = [ current ]; if (this.searchAll) { tabs.push.apply(tabs, sessions.getAllTabs().filter(function(t) { return t !== current })); @@ -221,7 +223,7 @@ define([ } }); tabs = results; - } else if (reference) { + } else if (reference !== false) { try { var crawl = new RegExp(reference.replace(/([.\[\]\(\)*\{\}])/g, "\\$1"), "i"); } catch (e) { @@ -268,6 +270,7 @@ define([ if (!current.retainFocus) editor.focus(); }, activate: function(mode) { + this.homeTab = sessions.getCurrent(); this.results = []; this.cache = {}; this.selected = 0; diff --git a/manifest.json b/manifest.json index 0667433..1d9c962 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "Caret", "description": "Professional text editing for Chrome and Chrome OS", - "version": "1.1.6", + "version": "1.1.7", "manifest_version": 2, "icons": { "128": "icon-128-2.png"