Skip to content

Commit

Permalink
Prevent backspacing to the previous command
Browse files Browse the repository at this point in the history
related to #8
  • Loading branch information
misfo committed Mar 26, 2012
1 parent bfabb07 commit 61c512e
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 8 deletions.
28 changes: 20 additions & 8 deletions Default.sublime-keymap
Expand Up @@ -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"}]
Expand All @@ -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 }
]
}
]
6 changes: 6 additions & 0 deletions sublime_readline.py
Expand Up @@ -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')

0 comments on commit 61c512e

Please sign in to comment.