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({
|
||||
name: "del",
|
||||
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({
|
||||
name: "backspace",
|
||||
|
|
@ -311,7 +311,7 @@ canon.addCommand({
|
|||
"Ctrl-Backspace|Command-Backspace|Option-Backspace|Shift-Backspace|Backspace",
|
||||
"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({
|
||||
name: "removetolinestart",
|
||||
|
|
|
|||
|
|
@ -656,32 +656,26 @@ var Editor =function(renderer, session) {
|
|||
return this.$modeBehaviours;
|
||||
};
|
||||
|
||||
this.removeRight = function() {
|
||||
this.remove = function(dir) {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
if (this.selection.isEmpty()) {
|
||||
this.selection.selectRight();
|
||||
}
|
||||
this.session.remove(this.getSelectionRange());
|
||||
this.clearSelection();
|
||||
};
|
||||
|
||||
this.removeLeft = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
if (this.selection.isEmpty())
|
||||
this.selection.selectLeft();
|
||||
if (this.selection.isEmpty()){
|
||||
if(dir == "left")
|
||||
this.selection.selectLeft();
|
||||
else
|
||||
this.selection.selectRight();
|
||||
}
|
||||
|
||||
var range = this.getSelectionRange();
|
||||
if (this.getBehavioursEnabled()) {
|
||||
var session = this.session;
|
||||
var state = session.getState(range.start.row);
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
this.session.remove(range);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue