Factor out mode transforms into Behaviour
This commit is contained in:
parent
1261c55913
commit
3cdfa37427
5 changed files with 306 additions and 62 deletions
|
|
@ -412,8 +412,9 @@ var Editor =function(renderer, session) {
|
|||
var mode = session.getMode();
|
||||
|
||||
var cursor = this.getCursorPosition();
|
||||
var transform = mode.transformInsert(session.getState(cursor.row), this, session, text);
|
||||
|
||||
// Get a transform if the current mode wants one.
|
||||
var transform = mode.transformInsert(session.getState(cursor.row), this, session, text);
|
||||
if (transform)
|
||||
text = transform.text;
|
||||
|
||||
|
|
@ -440,9 +441,17 @@ var Editor =function(renderer, session) {
|
|||
var end = session.insert(cursor, text);
|
||||
|
||||
if (transform && transform.selection) {
|
||||
this.selection.setSelectionRange(
|
||||
new Range(cursor.row, start + transform.selection[0],
|
||||
cursor.row, start + transform.selection[1]));
|
||||
if (transform.selection.length == 2) { // Transform relative to the current column
|
||||
this.selection.setSelectionRange(
|
||||
new Range(cursor.row, start + transform.selection[0],
|
||||
cursor.row, start + transform.selection[1]));
|
||||
} else { // Transform relative to the current row.
|
||||
this.selection.setSelectionRange(
|
||||
new Range(cursor.row + transform.selection[0],
|
||||
transform.selection[1],
|
||||
cursor.row + transform.selection[2],
|
||||
transform.selection[3]));
|
||||
}
|
||||
}
|
||||
|
||||
var lineState = session.getState(cursor.row);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue