parent
ec8124c394
commit
841f39c57b
2 changed files with 34 additions and 0 deletions
|
|
@ -43,6 +43,13 @@ var lang = require("pilot/lang");
|
||||||
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
var EventEmitter = require("pilot/event_emitter").EventEmitter;
|
||||||
var Range = require("ace/range").Range;
|
var Range = require("ace/range").Range;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Keeps cursor position and the text selection of an edit session.
|
||||||
|
*
|
||||||
|
* The row/columns used in the selection are in document coordinates
|
||||||
|
* representing ths coordinates as thez appear in the document
|
||||||
|
* before applying soft wrap and folding.
|
||||||
|
*/
|
||||||
var Selection = function(session) {
|
var Selection = function(session) {
|
||||||
this.session = session;
|
this.session = session;
|
||||||
this.doc = session.getDocument();
|
this.doc = session.getDocument();
|
||||||
|
|
|
||||||
|
|
@ -380,6 +380,20 @@ module.exports = {
|
||||||
assert.position(selection.getCursor(), 0, 0);
|
assert.position(selection.getCursor(), 0, 0);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"test: (wrap) go line up when in the middle of the first line should go to document start": function() {
|
||||||
|
var session = new EditSession("juhu kinners");
|
||||||
|
session.setWrapLimitRange(5, 5);
|
||||||
|
session.adjustWrapLimit(80);
|
||||||
|
|
||||||
|
var selection = session.getSelection();
|
||||||
|
|
||||||
|
selection.moveCursorTo(0, 4);
|
||||||
|
selection.moveCursorUp();
|
||||||
|
|
||||||
|
assert.position(selection.getCursor(), 0, 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
"test go line down when in the middle of the last line should go to document end": function() {
|
"test go line down when in the middle of the last line should go to document end": function() {
|
||||||
var session = new EditSession("juhu kinners");
|
var session = new EditSession("juhu kinners");
|
||||||
var selection = session.getSelection();
|
var selection = session.getSelection();
|
||||||
|
|
@ -390,6 +404,19 @@ module.exports = {
|
||||||
assert.position(selection.getCursor(), 0, 12);
|
assert.position(selection.getCursor(), 0, 12);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
"test (wrap) go line down when in the middle of the last line should go to document end": function() {
|
||||||
|
var session = new EditSession("juhu kinners");
|
||||||
|
session.setWrapLimitRange(8, 8);
|
||||||
|
session.adjustWrapLimit(80);
|
||||||
|
|
||||||
|
var selection = session.getSelection();
|
||||||
|
|
||||||
|
selection.moveCursorTo(0, 10);
|
||||||
|
selection.moveCursorDown();
|
||||||
|
|
||||||
|
assert.position(selection.getCursor(), 0, 12);
|
||||||
|
},
|
||||||
|
|
||||||
"test go line up twice and then once down when in the second should go back to the previous column": function() {
|
"test go line up twice and then once down when in the second should go back to the previous column": function() {
|
||||||
var session = new EditSession("juhu\nkinners");
|
var session = new EditSession("juhu\nkinners");
|
||||||
var selection = session.getSelection();
|
var selection = session.getSelection();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue