diff --git a/Default.sublime-keymap b/Default.sublime-keymap index 6a20540..30df005 100644 --- a/Default.sublime-keymap +++ b/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 } + ] } ] diff --git a/sublime_readline.py b/sublime_readline.py index 84b103b..a93962e 100644 --- a/sublime_readline.py +++ b/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') \ No newline at end of file