Sublime Forum

Custom Fast Move command behaving strangly with some keybindings

#1

I have been using a simple slightly modified version of the move command that executes a set number of times defined in settings in my plugin and it works great when using alt+arrowkeys to trigger the command but If I use alt+i/alt+j/alt+k/alt+l (The keys I almost always use to move around the buffer because I have it setup so I almost never move my hand from the center of the keyboard) it behaves strangely and kind of “sticks” to the last used movement command.

Here is the Python code for my command:

class FastMoveCommand(sublime_plugin.TextCommand):
def run(self, edit, direction, extend=False):
    window = sublime.active_window()
    if direction == "up":
        for i in range(settings.get("fast_move_vertical_move_amount")):
            window.run_command(
                "move", {"by": "lines", "forward": False, "extend": extend})
    if direction == "down":
        for i in range(settings.get("fast_move_vertical_move_amount")):
            window.run_command(
                "move", {"by": "lines", "forward": True, "extend": extend})
    if direction == "left":
        for i in range(settings.get("fast_move_horizontal_character_amount")):
            window.run_command(
                "move", {"by": "characters", "forward": False, "extend": extend})
    if direction == "right":
        for i in range(settings.get("fast_move_horizontal_character_amount")):
            window.run_command(
                "move", {"by": "characters", "forward": True, "extend": extend})

These are the keybindings that call this command and function correctly without the “sticking”

{ "keys": ["alt+up"], "command": "fast_move", "args": {"direction": "up"}},
{ "keys": ["alt+down"], "command": "fast_move", "args": {"direction": "down"}},
{ "keys": ["alt+right"], "command": "fast_move", "args": {"direction": "right"}},
{ "keys": ["alt+left"], "command": "fast_move", "args": {"direction": "left"}},

These are the keybindings that I really prefer to use but have the “sticking” bug when moving from one direction to another (up to down for example) so they aren’t useful because of it.

{ "keys": ["alt+i"], "command": "fast_move", "args": {"direction": "up"}},
{ "keys": ["alt+k"], "command": "fast_move", "args": {"direction": "down"}},
{ "keys": ["alt+l"], "command": "fast_move", "args": {"direction": "right"}},
{ "keys": ["alt+j"], "command": "fast_move", "args": {"direction": "left"}},

I’ve had this problem for a few months now and have tried to fix it a few times but I really have no idea what could possibly be causing it because the python code is fine and it works with the arrowkeys. Any help would be great.

0 Likes