togglecomment should not scroll if part of the selection is visible
This commit is contained in:
parent
5b151a3db4
commit
b6a4a34fd2
1 changed files with 18 additions and 16 deletions
|
|
@ -133,7 +133,6 @@ var Editor = function(renderer, session) {
|
||||||
if (command.aceCommandGroup == "fileJump") {
|
if (command.aceCommandGroup == "fileJump") {
|
||||||
if (this.lastFileJumpPos && !this.curOp.selectionChanged) {
|
if (this.lastFileJumpPos && !this.curOp.selectionChanged) {
|
||||||
this.selection.fromJSON(this.lastFileJumpPos);
|
this.selection.fromJSON(this.lastFileJumpPos);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.endOperation(e);
|
this.endOperation(e);
|
||||||
|
|
@ -168,7 +167,8 @@ var Editor = function(renderer, session) {
|
||||||
this.$opResetTimer.schedule();
|
this.$opResetTimer.schedule();
|
||||||
this.curOp = {
|
this.curOp = {
|
||||||
command: commadEvent.command || {},
|
command: commadEvent.command || {},
|
||||||
args: commadEvent.args
|
args: commadEvent.args,
|
||||||
|
scrollTop: this.renderer.scrollTop
|
||||||
};
|
};
|
||||||
|
|
||||||
var command = this.curOp.command;
|
var command = this.curOp.command;
|
||||||
|
|
@ -187,16 +187,24 @@ var Editor = function(renderer, session) {
|
||||||
case "center":
|
case "center":
|
||||||
this.renderer.scrollCursorIntoView(null, 0.5);
|
this.renderer.scrollCursorIntoView(null, 0.5);
|
||||||
break;
|
break;
|
||||||
|
case "animate":
|
||||||
case "cursor":
|
case "cursor":
|
||||||
this.renderer.scrollCursorIntoView();
|
this.renderer.scrollCursorIntoView();
|
||||||
break;
|
break;
|
||||||
case "selectionPart":
|
case "selectionPart":
|
||||||
this.renderer.scrollCursorIntoView();
|
var range = this.selection.getRange();
|
||||||
|
var config = this.renderer.layerConfig;
|
||||||
|
if (range.start.row >= config.lastRow || range.end.row <= config.firstRow) {
|
||||||
|
this.renderer.scrollSelectionIntoView(this.selection.anchor, this.selection.lead);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
if (command.scrollIntoView == "animate")
|
||||||
|
this.renderer.animateScrolling(this.curOp.scrollTop);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.prevOp = this.curOp;
|
this.prevOp = this.curOp;
|
||||||
this.curOp = null;
|
this.curOp = null;
|
||||||
}
|
}
|
||||||
|
|
@ -243,7 +251,6 @@ var Editor = function(renderer, session) {
|
||||||
* Sets a new key handler, such as "vim" or "windows".
|
* Sets a new key handler, such as "vim" or "windows".
|
||||||
* @param {String} keyboardHandler The new key handler
|
* @param {String} keyboardHandler The new key handler
|
||||||
*
|
*
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
this.setKeyboardHandler = function(keyboardHandler) {
|
this.setKeyboardHandler = function(keyboardHandler) {
|
||||||
if (!keyboardHandler) {
|
if (!keyboardHandler) {
|
||||||
|
|
@ -277,7 +284,6 @@ var Editor = function(renderer, session) {
|
||||||
* @event changeSession
|
* @event changeSession
|
||||||
* @param {Object} e An object with two properties, `oldSession` and `session`, that represent the old and new [[EditSession]]s.
|
* @param {Object} e An object with two properties, `oldSession` and `session`, that represent the old and new [[EditSession]]s.
|
||||||
*
|
*
|
||||||
*
|
|
||||||
**/
|
**/
|
||||||
/**
|
/**
|
||||||
* Sets a new editsession to use. This method also emits the `'changeSession'` event.
|
* Sets a new editsession to use. This method also emits the `'changeSession'` event.
|
||||||
|
|
@ -875,7 +881,7 @@ var Editor = function(renderer, session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (text == "\n" || text == "\r\n") {
|
if (text == "\n" || text == "\r\n") {
|
||||||
var line = session.getLine(cursor.row)
|
var line = session.getLine(cursor.row);
|
||||||
if (cursor.column > line.search(/\S|$/)) {
|
if (cursor.column > line.search(/\S|$/)) {
|
||||||
var d = line.substr(cursor.column).search(/\S|$/);
|
var d = line.substr(cursor.column).search(/\S|$/);
|
||||||
session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
|
session.doc.removeInLine(cursor.row, cursor.column, cursor.column + d);
|
||||||
|
|
@ -1202,7 +1208,7 @@ var Editor = function(renderer, session) {
|
||||||
var state = session.getState(range.start.row);
|
var state = session.getState(range.start.row);
|
||||||
var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
|
var new_range = session.getMode().transformAction(state, 'deletion', this, session, range);
|
||||||
|
|
||||||
if (range.end.column == 0) {
|
if (range.end.column === 0) {
|
||||||
var text = session.getTextRange(range);
|
var text = session.getTextRange(range);
|
||||||
if (text[text.length - 1] == "\n") {
|
if (text[text.length - 1] == "\n") {
|
||||||
var line = session.getLine(range.end.row);
|
var line = session.getLine(range.end.row);
|
||||||
|
|
@ -1361,7 +1367,7 @@ var Editor = function(renderer, session) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var line = session.getLine(range.start.row)
|
var line = session.getLine(range.start.row);
|
||||||
var position = range.start;
|
var position = range.start;
|
||||||
var size = session.getTabSize();
|
var size = session.getTabSize();
|
||||||
var column = session.documentToScreenColumn(position.row, position.column);
|
var column = session.documentToScreenColumn(position.row, position.column);
|
||||||
|
|
@ -1632,7 +1638,7 @@ var Editor = function(renderer, session) {
|
||||||
var last = rows.end.row;
|
var last = rows.end.row;
|
||||||
var first = rows.start.row;
|
var first = rows.start.row;
|
||||||
while (i--) {
|
while (i--) {
|
||||||
var rows = ranges[i].collapseRows();
|
rows = ranges[i].collapseRows();
|
||||||
if (first - rows.end.row <= 1)
|
if (first - rows.end.row <= 1)
|
||||||
first = rows.end.row;
|
first = rows.end.row;
|
||||||
else
|
else
|
||||||
|
|
@ -1736,11 +1742,11 @@ var Editor = function(renderer, session) {
|
||||||
var rows = dir * Math.floor(config.height / config.lineHeight);
|
var rows = dir * Math.floor(config.height / config.lineHeight);
|
||||||
|
|
||||||
this.$blockScrolling++;
|
this.$blockScrolling++;
|
||||||
if (select == true) {
|
if (select === true) {
|
||||||
this.selection.$moveSelection(function(){
|
this.selection.$moveSelection(function(){
|
||||||
this.moveCursorBy(rows, 0);
|
this.moveCursorBy(rows, 0);
|
||||||
});
|
});
|
||||||
} else if (select == false) {
|
} else if (select === false) {
|
||||||
this.selection.moveCursorBy(rows, 0);
|
this.selection.moveCursorBy(rows, 0);
|
||||||
this.selection.clearSelection();
|
this.selection.clearSelection();
|
||||||
}
|
}
|
||||||
|
|
@ -2069,10 +2075,8 @@ var Editor = function(renderer, session) {
|
||||||
* Moves the cursor to the end of the current file. Note that this does de-select the current selection.
|
* Moves the cursor to the end of the current file. Note that this does de-select the current selection.
|
||||||
**/
|
**/
|
||||||
this.navigateFileEnd = function() {
|
this.navigateFileEnd = function() {
|
||||||
var scrollTop = this.renderer.scrollTop;
|
|
||||||
this.selection.moveCursorFileEnd();
|
this.selection.moveCursorFileEnd();
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
this.renderer.animateScrolling(scrollTop);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2080,10 +2084,8 @@ var Editor = function(renderer, session) {
|
||||||
* Moves the cursor to the start of the current file. Note that this does de-select the current selection.
|
* Moves the cursor to the start of the current file. Note that this does de-select the current selection.
|
||||||
**/
|
**/
|
||||||
this.navigateFileStart = function() {
|
this.navigateFileStart = function() {
|
||||||
var scrollTop = this.renderer.scrollTop;
|
|
||||||
this.selection.moveCursorFileStart();
|
this.selection.moveCursorFileStart();
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
this.renderer.animateScrolling(scrollTop);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -2266,7 +2268,7 @@ var Editor = function(renderer, session) {
|
||||||
|
|
||||||
var scrollTop = this.renderer.scrollTop;
|
var scrollTop = this.renderer.scrollTop;
|
||||||
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
|
this.renderer.scrollSelectionIntoView(range.start, range.end, 0.5);
|
||||||
if (animate != false)
|
if (animate !== false)
|
||||||
this.renderer.animateScrolling(scrollTop);
|
this.renderer.animateScrolling(scrollTop);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue