From f6209e97de1ee1badd005dff1dc4450c62563cfe Mon Sep 17 00:00:00 2001 From: Maurice Zhang Date: Fri, 3 Jul 2015 23:47:21 -0400 Subject: [PATCH] Fix bug that added a semi colon when adding a new line even if there was already one --- AppendSemiColon.py | 5 ++++- AppendSemiColon.sublime-macro | 23 ----------------------- Default (OSX).sublime-keymap | 2 +- Default.sublime-keymap | 2 +- 4 files changed, 6 insertions(+), 26 deletions(-) delete mode 100644 AppendSemiColon.sublime-macro diff --git a/AppendSemiColon.py b/AppendSemiColon.py index cbf85d4..6d5a701 100644 --- a/AppendSemiColon.py +++ b/AppendSemiColon.py @@ -1,7 +1,7 @@ import sublime_plugin class AppendSemiColonCommand(sublime_plugin.TextCommand): - def run(self, edit): + def run(self, edit, **args): def insert_semicolon(point): self.view.insert(edit, point, ';') @@ -34,3 +34,6 @@ def is_semicolon(point): elif not is_semicolon(line_end - 1): insert_semicolon(line_end) + + if ('enter_new_line' in args and args['enter_new_line'] == 'true'): + self.view.run_command("run_macro_file", {"file": "Packages/Default/Add Line.sublime-macro"}) # enter new line diff --git a/AppendSemiColon.sublime-macro b/AppendSemiColon.sublime-macro deleted file mode 100644 index 719e200..0000000 --- a/AppendSemiColon.sublime-macro +++ /dev/null @@ -1,23 +0,0 @@ -[ - { - "args": - { - "to": "eol" - }, - "command": "move_to" - }, - { - "args": - { - "characters": ";" - }, - "command": "insert" - }, - { - "args": - { - "characters": "\n" - }, - "command": "insert" - } -] diff --git a/Default (OSX).sublime-keymap b/Default (OSX).sublime-keymap index 96549bc..f1f47c7 100644 --- a/Default (OSX).sublime-keymap +++ b/Default (OSX).sublime-keymap @@ -1,4 +1,4 @@ [ { "keys": ["super+;"], "command": "append_semi_colon" }, - { "keys": ["super+shift+;"], "command": "run_macro_file", "args": {"file": "Packages/AppendSemiColon/AppendSemiColon.sublime-macro"} } + { "keys": ["super+shift+;"], "command": "append_semi_colon", "args": {"enter_new_line": "true"} } ] diff --git a/Default.sublime-keymap b/Default.sublime-keymap index bae8945..db5c787 100644 --- a/Default.sublime-keymap +++ b/Default.sublime-keymap @@ -1,4 +1,4 @@ [ { "keys": ["ctrl+;"], "command": "append_semi_colon" }, - { "keys": ["ctrl+shift+;"], "command": "run_macro_file", "args": {"file": "Packages/AppendSemiColon/AppendSemiColon.sublime-macro"} } + { "keys": ["ctrl+shift+;"], "command": "append_semi_colon", "args": {"enter_new_line": "true"} } ]