Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Prevent backspacing to the previous command

related to #8
  • Loading branch information...
commit 61c512e9f167a6b264b15fa656caa0eeb5f1a74d 1 parent bfabb07
@misfo authored
Showing with 26 additions and 8 deletions.
  1. +20 −8 Default.sublime-keymap
  2. +6 −0 sublime_readline.py
View
28 Default.sublime-keymap
@@ -8,14 +8,6 @@
"args": {"movement": "move", "movement_args": {"by": "lines", "forward": true}},
"context": [{"key": "setting.readline_input_widget"}]
},
- {"keys": ["shift+up"], "command": "readline_history_change",
- "args": {"movement": "move", "movement_args": {"by": "lines", "forward": false}},
- "context": [{"key": "setting.readline_input_widget"}]
- },
- {"keys": ["shift+down"], "command": "readline_history_change",
- "args": {"movement": "move", "movement_args": {"by": "lines", "forward": true}},
- "context": [{"key": "setting.readline_input_widget"}]
- },
{"keys": ["ctrl+a"], "command": "move_to",
"args": {"to": "bol"},
"context": [{"key": "setting.readline_input_widget"}]
@@ -27,5 +19,25 @@
{"keys": ["ctrl+u"], "command": "run_macro_file",
"args": {"file": "Packages/Default/Delete to Hard BOL.sublime-macro"},
"context": [{"key": "setting.readline_input_widget"}]
+ },
+
+
+ // The remaining keybindings are less to add functionality and more to
+ // prevent strange behavior that results from the input widget being a
+ // multi-line view.
+ {"keys": ["shift+up"], "command": "readline_history_change",
+ "args": {"movement": "move", "movement_args": {"by": "lines", "forward": false}},
+ "context": [{"key": "setting.readline_input_widget"}]
+ },
+ {"keys": ["shift+down"], "command": "readline_history_change",
+ "args": {"movement": "move", "movement_args": {"by": "lines", "forward": true}},
+ "context": [{"key": "setting.readline_input_widget"}]
+ },
+ {"keys": ["backspace"], "command": "left_delete_on_line",
+ "context": [
+ { "key": "setting.readline_input_widget" },
+ { "key": "num_selections", "operand": 1 },
+ { "key": "selection_empty", "operator": "equal", "operand": true }
+ ]
}
]
View
6 sublime_readline.py
@@ -36,3 +36,9 @@ def run(self, movement, movement_args):
self.view.run_command("move_to", {"to": "eol", "extend": False})
global active_input_row
active_input_row, _ = self.view.rowcol(self.view.sel()[0].b)
+
+class LeftDeleteOnLine(sublime_plugin.TextCommand):
+ def run(self, edit):
+ if self.view.rowcol(self.view.sel()[0].b)[1]:
+ # Don't left delete if the cursor is at the beginning of the line
+ self.view.run_command('left_delete')
Please sign in to comment.
Something went wrong with that request. Please try again.