Permalink
Browse files

Merge pull request #5 from ajaxorg/fix/find-node

Fix findNode
  • Loading branch information...
2 parents 6417527 + 46dea1d commit c7ee419c6c985d4369d71619b8e97044de3e502e @zefhemel zefhemel committed May 15, 2012
Showing with 6 additions and 6 deletions.
  1. +6 −6 lib/treehugger/tree.js
@@ -1,15 +1,15 @@
define(function(require, exports, module) {
function inRange(p, pos) {
- if(p && p.sl <= pos.line && p.el >= pos.line) {
- if(p.sl < pos.line && p.el > pos.line)
+ if(p && p.sl <= pos.line && pos.line <= p.el) {
+ if(p.sl < pos.line && pos.line < p.el)
return true;
- else if(p.sl == pos.line && p.el > pos.line)
+ else if(p.sl == pos.line && pos.line < p.el)
return p.sc <= pos.col;
else if(p.sl == pos.line && p.el === pos.line)
- return p.sc <= pos.col && p.ec >= pos.col;
+ return p.sc <= pos.col && pos.col <= p.ec;
else if(p.sl < pos.line && p.el === pos.line)
- return p.ec >= pos.col;
+ return pos.col <= p.ec;
}
}
@@ -202,7 +202,7 @@ ConsNode.prototype.findNode = function(pos) {
var node = this[i].findNode(pos);
if(node)
return node instanceof StringNode ? this : node;
- else
+ else if(p2.sl == p2.el)
return this[i];
}
}

0 comments on commit c7ee419

Please sign in to comment.