From 841f39c57bd2f77945ac9faa7d237163ce6ba0d9 Mon Sep 17 00:00:00 2001 From: Fabian Jakobs Date: Fri, 22 Jul 2011 12:19:43 +0200 Subject: [PATCH] Verify that #185 is already fixed. fix #185 --- lib/ace/selection.js | 7 +++++++ lib/ace/selection_test.js | 27 +++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/lib/ace/selection.js b/lib/ace/selection.js index 394f8266..65e0fec5 100644 --- a/lib/ace/selection.js +++ b/lib/ace/selection.js @@ -43,6 +43,13 @@ var lang = require("pilot/lang"); var EventEmitter = require("pilot/event_emitter").EventEmitter; 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) { this.session = session; this.doc = session.getDocument(); diff --git a/lib/ace/selection_test.js b/lib/ace/selection_test.js index da76de45..30295da9 100644 --- a/lib/ace/selection_test.js +++ b/lib/ace/selection_test.js @@ -380,6 +380,20 @@ module.exports = { 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() { var session = new EditSession("juhu kinners"); var selection = session.getSelection(); @@ -390,6 +404,19 @@ module.exports = { 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() { var session = new EditSession("juhu\nkinners"); var selection = session.getSelection();