Skip to content

Commit

Permalink
Fixed bug with invalid selection of previous item in CSS
Browse files Browse the repository at this point in the history
  • Loading branch information
sergeche committed May 7, 2014
1 parent 09ba971 commit 73ccb74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 5 additions & 3 deletions lib/action/selectItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -383,9 +383,11 @@ define(function(require, exports, module) {
}

// return range next to caret
r = _.find(ranges, function(item) {
return item.end > selRange.start;
});
var test =
r = _.find(ranges, isBackward
? function(item) {return item.end < selRange.start;}
: function(item) {return item.end > selRange.start;}
);

if (!r) {
// can’t find anything, just pick first one
Expand Down
4 changes: 4 additions & 0 deletions test/actions/selectItem.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,10 @@ describe('Select Next/Previous Item action', function() {
assert.deepEqual(next(), r(24, 38));
assert.deepEqual(next(), r(28, 37));
assert.deepEqual(next(), r(39, 48));

// edge case, previously buggy
editor.replaceContent('a{b:c; ${0} d:e;}');
assert.deepEqual(prev(), r(4, 5));

editor.setSyntax('html');
});
Expand Down

0 comments on commit 73ccb74

Please sign in to comment.