commit
45f351e819
3 changed files with 75 additions and 5 deletions
|
|
@ -11855,9 +11855,26 @@ var Selection = function(session) {
|
||||||
this.selectionLead.row,
|
this.selectionLead.row,
|
||||||
this.selectionLead.column
|
this.selectionLead.column
|
||||||
);
|
);
|
||||||
var screenCol = (chars == 0 && this.$desiredColumn) || screenPos.column;
|
|
||||||
|
var screenCol = (chars === 0 && this.$desiredColumn) || screenPos.column;
|
||||||
|
|
||||||
|
// so here is the deal. First checkout what the content of ur current and ur target line is
|
||||||
|
var currentLine = (this.session.getLines(screenPos.row, screenPos.row) || [""])[0],
|
||||||
|
targetLine = (this.session.getLines(screenPos.row + rows, screenPos.row + rows) || [""])[0];
|
||||||
|
|
||||||
|
// if you are at the EOL of your current line, and your targetline is all whitespace
|
||||||
|
if (currentLine && targetLine &&
|
||||||
|
currentLine.length === screenPos.column && targetLine.match(/^\s*$/)) {
|
||||||
|
// set the new column to the EOL of the target line
|
||||||
|
screenCol = this.session.getTabString(targetLine).length;
|
||||||
|
// update the chars so we are sure that the desired column will be updated
|
||||||
|
chars = 1;
|
||||||
|
};
|
||||||
|
|
||||||
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol);
|
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol);
|
||||||
this.moveCursorTo(docPos.row, docPos.column + chars, chars == 0);
|
|
||||||
|
// move the cursor and update the desired column
|
||||||
|
this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.moveCursorToPosition = function(position) {
|
this.moveCursorToPosition = function(position) {
|
||||||
|
|
|
||||||
|
|
@ -123,7 +123,7 @@ var Selection = function(session) {
|
||||||
};
|
};
|
||||||
|
|
||||||
var anchor = this.getSelectionAnchor();
|
var anchor = this.getSelectionAnchor();
|
||||||
var lead = this.getSelectionLead();
|
var lead = this.getSelectionLead();
|
||||||
|
|
||||||
var isBackwards = this.isBackwards();
|
var isBackwards = this.isBackwards();
|
||||||
|
|
||||||
|
|
@ -440,9 +440,26 @@ var Selection = function(session) {
|
||||||
this.selectionLead.row,
|
this.selectionLead.row,
|
||||||
this.selectionLead.column
|
this.selectionLead.column
|
||||||
);
|
);
|
||||||
var screenCol = (chars == 0 && this.$desiredColumn) || screenPos.column;
|
|
||||||
|
var screenCol = (chars === 0 && this.$desiredColumn) || screenPos.column;
|
||||||
|
|
||||||
|
// so here is the deal. First checkout what the content of ur current and ur target line is
|
||||||
|
var currentLine = (this.session.getLines(screenPos.row, screenPos.row) || [""])[0],
|
||||||
|
targetLine = (this.session.getLines(screenPos.row + rows, screenPos.row + rows) || [""])[0];
|
||||||
|
|
||||||
|
// if you are at the EOL of your current line, and your targetline is all whitespace
|
||||||
|
if (currentLine && targetLine &&
|
||||||
|
currentLine.length === screenPos.column && targetLine.match(/^\s*$/)) {
|
||||||
|
// set the new column to the EOL of the target line
|
||||||
|
screenCol = this.session.getTabString(targetLine).length;
|
||||||
|
// update the chars so we are sure that the desired column will be updated
|
||||||
|
chars = 1;
|
||||||
|
};
|
||||||
|
|
||||||
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol);
|
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol);
|
||||||
this.moveCursorTo(docPos.row, docPos.column + chars, chars == 0);
|
|
||||||
|
// move the cursor and update the desired column
|
||||||
|
this.moveCursorTo(docPos.row, docPos.column + chars, chars === 0);
|
||||||
};
|
};
|
||||||
|
|
||||||
this.moveCursorToPosition = function(position) {
|
this.moveCursorToPosition = function(position) {
|
||||||
|
|
|
||||||
|
|
@ -442,6 +442,42 @@ module.exports = {
|
||||||
selection.moveCursorUp();
|
selection.moveCursorUp();
|
||||||
selection.moveCursorDown();
|
selection.moveCursorDown();
|
||||||
|
|
||||||
|
assert.position(selection.getCursor(), 1, 4);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test (keyboard navigation) when curLine is EOL and targetLine is all whitespace new column should be targetLine's EOL": function() {
|
||||||
|
var session = new EditSession("function (a) {\n\
|
||||||
|
\n\
|
||||||
|
}");
|
||||||
|
var selection = session.getSelection();
|
||||||
|
|
||||||
|
selection.moveCursorTo(2, 1);
|
||||||
|
selection.moveCursorUp();
|
||||||
|
|
||||||
|
assert.position(selection.getCursor(), 1, 4);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test (keyboard navigation) when curLine is not EOL and targetLine is all whitespace new column should be current column": function() {
|
||||||
|
var session = new EditSession("function (a) {\n\
|
||||||
|
\n\
|
||||||
|
}");
|
||||||
|
var selection = session.getSelection();
|
||||||
|
|
||||||
|
selection.moveCursorTo(2, 0);
|
||||||
|
selection.moveCursorUp();
|
||||||
|
|
||||||
|
assert.position(selection.getCursor(), 1, 0);
|
||||||
|
},
|
||||||
|
|
||||||
|
"test (keyboard navigation) when curLine is EOL and targetLine is shorter dan current column, new column should be targetLine's EOL": function() {
|
||||||
|
var session = new EditSession("function (a) {\n\
|
||||||
|
\n\
|
||||||
|
}");
|
||||||
|
var selection = session.getSelection();
|
||||||
|
|
||||||
|
selection.moveCursorTo(0, 14);
|
||||||
|
selection.moveCursorDown();
|
||||||
|
|
||||||
assert.position(selection.getCursor(), 1, 4);
|
assert.position(selection.getCursor(), 1, 4);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue