allow behaviours to handle removeRight as well
This commit is contained in:
parent
fdb8372597
commit
a2cd7be899
2 changed files with 12 additions and 18 deletions
|
|
@ -303,7 +303,7 @@ canon.addCommand({
|
||||||
canon.addCommand({
|
canon.addCommand({
|
||||||
name: "del",
|
name: "del",
|
||||||
bindKey: bindKey("Delete", "Delete|Ctrl-D"),
|
bindKey: bindKey("Delete", "Delete|Ctrl-D"),
|
||||||
exec: function(env, args, request) { env.editor.removeRight(); }
|
exec: function(env, args, request) { env.editor.remove("right"); }
|
||||||
});
|
});
|
||||||
canon.addCommand({
|
canon.addCommand({
|
||||||
name: "backspace",
|
name: "backspace",
|
||||||
|
|
@ -311,7 +311,7 @@ canon.addCommand({
|
||||||
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
|
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
|
||||||
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
|
"Ctrl-Backspace|Command-Backspace|Shift-Backspace|Backspace|Ctrl-H"
|
||||||
),
|
),
|
||||||
exec: function(env, args, request) { env.editor.removeLeft(); }
|
exec: function(env, args, request) { env.editor.remove("left"); }
|
||||||
});
|
});
|
||||||
canon.addCommand({
|
canon.addCommand({
|
||||||
name: "removetolinestart",
|
name: "removetolinestart",
|
||||||
|
|
|
||||||
|
|
@ -656,33 +656,27 @@ var Editor =function(renderer, session) {
|
||||||
return this.$modeBehaviours;
|
return this.$modeBehaviours;
|
||||||
};
|
};
|
||||||
|
|
||||||
this.removeRight = function() {
|
this.remove = function(dir) {
|
||||||
if (this.$readOnly)
|
if (this.$readOnly)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (this.selection.isEmpty()) {
|
if (this.selection.isEmpty()){
|
||||||
|
if(dir == "left")
|
||||||
|
this.selection.selectLeft();
|
||||||
|
else
|
||||||
this.selection.selectRight();
|
this.selection.selectRight();
|
||||||
}
|
}
|
||||||
this.session.remove(this.getSelectionRange());
|
|
||||||
this.clearSelection();
|
|
||||||
};
|
|
||||||
|
|
||||||
this.removeLeft = function() {
|
|
||||||
if (this.$readOnly)
|
|
||||||
return;
|
|
||||||
|
|
||||||
if (this.selection.isEmpty())
|
|
||||||
this.selection.selectLeft();
|
|
||||||
|
|
||||||
var range = this.getSelectionRange();
|
var range = this.getSelectionRange();
|
||||||
if (this.getBehavioursEnabled()) {
|
if (this.getBehavioursEnabled()) {
|
||||||
var session = this.session;
|
var session = this.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 (new_range !== false) {
|
if (new_range === false)
|
||||||
|
return;
|
||||||
|
if (new_range)
|
||||||
range = new_range;
|
range = new_range;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
this.session.remove(range);
|
this.session.remove(range);
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue