From 23cbb3383320cd80dfe1f244a99d9b93c85314a8 Mon Sep 17 00:00:00 2001 From: nightwing Date: Wed, 30 Mar 2016 19:31:23 +0400 Subject: [PATCH] fix regression in stripws --- node_modules/ace/lib/ace/ext/whitespace.js | 4 ++-- node_modules/ace/lib/ace/ext/whitespace_test.js | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/node_modules/ace/lib/ace/ext/whitespace.js b/node_modules/ace/lib/ace/ext/whitespace.js index aa20c60a..04074988 100644 --- a/node_modules/ace/lib/ace/ext/whitespace.js +++ b/node_modules/ace/lib/ace/ext/whitespace.js @@ -131,7 +131,7 @@ exports.trimTrailingSpace = function(session, options) { if (options && options.keepCursorPosition) { if (session.selection.rangeCount) { session.selection.rangeList.ranges.forEach(function(x, i, ranges) { - var next = ranges[i + 1] + var next = ranges[i + 1]; if (next && next.cursor.row == x.cursor.row) return; cursors.push(x.cursor); @@ -148,7 +148,7 @@ exports.trimTrailingSpace = function(session, options) { var index = line.search(/\s+$/); if (i == cursorRow) { - if (index < cursors[ci].column) + if (index < cursors[ci].column && index > min) index = cursors[ci].column; ci++; cursorRow = cursors[ci] ? cursors[ci].row : -1; diff --git a/node_modules/ace/lib/ace/ext/whitespace_test.js b/node_modules/ace/lib/ace/ext/whitespace_test.js index cddc52ea..422d346c 100644 --- a/node_modules/ace/lib/ace/ext/whitespace_test.js +++ b/node_modules/ace/lib/ace/ext/whitespace_test.js @@ -183,6 +183,17 @@ module.exports = { trimEmpty: true, keepCursorPosition: true }); + + session.setValue("some text"); + session.selection.fromJSON([{ + start: {row:0,column:4}, + end: {row:0,column:4} + }]); + testOne("some text", { + keepCursorPosition: true, + trimEmpty: true + }); + next(); }, };