Skip to content

Commit

Permalink
Merge branch 'vim' of github.com:ajaxorg/cloud9 into vim
Browse files Browse the repository at this point in the history
  • Loading branch information
sergi committed Nov 30, 2011
2 parents 7ceb6b1 + d6345ae commit a72a987
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 276 deletions.
13 changes: 10 additions & 3 deletions client/ext/jslanguage/scope_analyzer.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,13 @@ handler.analyze = function(doc, ast) {
// Put back
scope[b.x.value] = oldVar;
return node;
},
'PropAccess(_, "lenght")', function(b, node) {
markers.push({
pos: node.getPos(),
type: 'warning',
message: "Did you mean 'length'?"
});
}
);
if(!parentLocalVars) {
Expand Down Expand Up @@ -206,11 +213,11 @@ handler.onCursorMovedNode = function(doc, fullAst, cursorPos, currentNode) {

handler.getVariablePositions = function(doc, fullAst, cursorPos, currentNode) {
var v;
var mainNode;
var mainNode;
currentNode.rewrite(
'VarDeclInit(x, _)', function(b, node) {
v = node.getAnnotation("scope")[b.x.value];
mainNode = b.x;
mainNode = b.x;
},
'VarDecl(x)', function(b, node) {
v = node.getAnnotation("scope")[b.x.value];
Expand All @@ -237,7 +244,7 @@ handler.getVariablePositions = function(doc, fullAst, cursorPos, currentNode) {
var length = pos.ec - pos.sc;

v.declarations.forEach(function(node) {
if(node !== currentNode[0]) {
if(node !== mainNode) {
var pos = node.getPos();
others.push({column: pos.sc, row: pos.sl});
}
Expand Down
111 changes: 84 additions & 27 deletions client/ext/quicksearch/quicksearch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ var Search = require("ace/search").Search;
var skin = require("text!ext/quicksearch/skin.xml");
var markup = require("text!ext/quicksearch/quicksearch.xml");

var oIter, oTotal;

module.exports = ext.register("ext/quicksearch/quicksearch", {
name : "quicksearch",
dev : "Ajax.org",
Expand All @@ -37,6 +39,8 @@ module.exports = ext.register("ext/quicksearch/quicksearch", {
hotitems: {},

nodes : [],

currentRange: null,

hook : function(){
var _self = this;
Expand All @@ -54,10 +58,7 @@ module.exports = ext.register("ext/quicksearch/quicksearch", {
txtQuickSearch.addEventListener("keydown", function(e){
switch (e.keyCode){
case 13: //ENTER
if (e.shiftKey)
_self.execSearch(false, true);
else
_self.execSearch(false, false);
_self.execSearch(false, !!e.shiftKey);
return false;
case 27: //ESCAPE
_self.toggleDialog(-1);
Expand Down Expand Up @@ -125,6 +126,54 @@ module.exports = ext.register("ext/quicksearch/quicksearch", {
if (e.keyCode == 27)
this.toggleDialog(-1);
},

updateCounter: function() {
var ace = this.$getAce();

if (!oIter) {
oIter = document.getElementById("spanSearchIter");
oTotal = document.getElementById("spanSearchTotal");
}

if (!ace || !winQuickSearch.visible) {
oIter.parentNode.style.width = "0px";
return;
}
else
oIter.parentNode.style.width = "auto";

setTimeout(function() {
var width = oIter.parentNode.offsetWidth || 0;
txtQuickSearch.$button.style.right = width + "px";
var buttonWidth = txtQuickSearch.$button.offsetWidth || 0;
txtQuickSearch.$input.parentNode.style.paddingRight = (width + buttonWidth + 10) + "px";
});

var ranges = ace.$search.findAll(ace.getSession());
if (!ranges || !ranges.length) {
oIter.innerHTML = "0"
oTotal.innerHTML = "of 0";
return;
}
var crtIdx = -1;
var cur = this.currentRange;
if (cur) {
// sort ranges by position in the current document
ranges.sort(cur.compareRange.bind(cur));
var range;
var start = cur.start;
var end = cur.end;
for (var i = 0, l = ranges.length; i < l; ++i) {
range = ranges[i];
if (range.isStart(start.row, start.column) && range.isEnd(end.row, end.column)) {
crtIdx = i;
break;
}
}
}
oIter.innerHTML = String(++crtIdx);
oTotal.innerHTML = "of " + ranges.length;
},

toggleDialog: function(force) {
ext.initExtension(this);
Expand All @@ -139,6 +188,8 @@ module.exports = ext.register("ext/quicksearch/quicksearch", {
if (!editor || !editor.ceEditor)
return;

var _self = this;

if (!force && !winQuickSearch.visible || force > 0) {
this.position = 0;

Expand Down Expand Up @@ -166,7 +217,10 @@ module.exports = ext.register("ext/quicksearch/quicksearch", {
to : 2,
steps : 8,
interval : 10,
control : (this.control = {})
control : (this.control = {}),
onfinish : function() {
_self.updateCounter();
}
});
}
else if (winQuickSearch.visible) {
Expand Down Expand Up @@ -197,33 +251,27 @@ module.exports = ext.register("ext/quicksearch/quicksearch", {
},

execSearch: function(close, backwards) {
var editor = editors.currentEditor;
if (!editor || !editor.ceEditor)
var ace = this.$getAce();
if (!ace)
return;

var ceEditor = editor.ceEditor;
var ace = ceEditor.$editor;

var txt = txtQuickSearch.getValue();
if (!txt)
return;

var options = {
backwards: backwards || false,
backwards: !!backwards,
wrap: true,
caseSensitive: false,
wholeWord: false,
regExp: false,
scope: Search.ALL
};

if (this.$crtSearch != txt) {
if (this.$crtSearch != txt)
this.$crtSearch = txt;
ace.find(txt, options);
}
else {
ace.find(txt, options);
}
ace.find(txt, options);
this.currentRange = ace.selection.getRange();

var settings = require("ext/settings/settings");
if (settings.model) {
Expand All @@ -239,8 +287,10 @@ module.exports = ext.register("ext/quicksearch/quicksearch", {

if (close) {
winQuickSearch.hide();
ceEditor.focus();
editors.currentEditor.ceEditor.focus();
}

this.updateCounter();
},

find: function() {
Expand All @@ -249,27 +299,34 @@ module.exports = ext.register("ext/quicksearch/quicksearch", {
},

findnext: function() {
var editor = editors.currentEditor;
if (!editor || !editor.ceEditor)
var ace = this.$getAce();
if (!ace)
return;

var ceEditor = editor.ceEditor;
var ace = ceEditor.$editor;

ace.findNext();
this.currentRange = ace.selection.getRange();
this.updateCounter();
return false;
},

findprevious: function() {
var ace = this.$getAce();
if (!ace)
return;

ace.findPrevious();
this.currentRange = ace.selection.getRange();
this.updateCounter();
return false;
},

$getAce: function() {
var editor = editors.currentEditor;
if (!editor || !editor.ceEditor)
return;

var ceEditor = editor.ceEditor;
var ace = ceEditor.$editor;

ace.findPrevious();
return false;
return ceEditor.$editor;
},

enable : function(){
Expand Down
1 change: 1 addition & 0 deletions client/ext/quicksearch/quicksearch.xml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
<a:button margin="0 0 0 5" skin="btnsearchicon" icon="rounded_close.png" onclick="
require('ext/quicksearch/quicksearch').toggleDialog(-1);
" />
<div id="divSearchCount"><span class="searchIter" id="spanSearchIter">0</span><span class="searchTotal" id="spanSearchTotal">0</span></div>
</a:hbox>
</a:bar>
</a:application>
Loading

0 comments on commit a72a987

Please sign in to comment.