[occur] entering and exiting occur: position is translated

This commit is contained in:
Robert Krahn 2013-03-17 04:11:34 -07:00
commit 204e6b5ab0
3 changed files with 76 additions and 0 deletions

View file

@ -70,6 +70,14 @@ module.exports = {
assert.equal(session.getValue(), lines.join('\n') + '\n');
},
"test: original position from occur doc" : function() {
session.doc.insertLines(0, ['abc', 'def', 'xyz', 'bcx']);
occur.display(session, {needle: 'bc'});
assert.equal(session.getValue(), 'abc\nbcx');
var pos = occur.occurToOriginalPosition(session, {row: 1, column: 2});
assert.position(pos, 3, 2);
},
"test: occur command" : function() {
// setup
var lines = ['hel', 'lo', '', 'wo', 'rld'];
@ -93,6 +101,25 @@ module.exports = {
assert.ok(!editor.getReadOnly(), 'original doc is marked as read only');
assert.ok(!editor.getKeyboardHandler().isOccurHandler, 'occur handler installed after detach');
assert.ok(!editor.commands.byName.occurexit, 'exitoccur installed after exiting occur');
},
"test: occur navigation" : function() {
// setup
var lines = ['hel', 'lo', '', 'wo', 'rld'];
session.doc.insertLines(0, lines);
editor.commands.addCommands(occurCommands);
editor.moveCursorToPosition({row: 1, column: 1});
// run occur for lines including 'o'
editor.execCommand('occur', {needle: 'o'});
assert.equal(session.getValue(), 'lo\nwo');
assert.position(editor.getCursorPosition(), 0, 1, 'original -> occur pos');
// move to second line and accept
editor.moveCursorToPosition({row: 1, column: 1});
editor.execCommand('occuraccept');
assert.position(editor.getCursorPosition(), 3, 1, 'occur -> original pos');
}
};