import sublime
import sublime_plugin

# To use appscript directly:
# sys.path.append('/Users/russell/.pyenv/versions/3/lib/python3.3/site-packages/aeosa')
# import appscript


@@ -37,139 +37,2293 @@
 %0A%0A# 
-To use appscript directly:%0A# sys.path.append('/Users/russell/.pyenv/versions/3/lib/python3.3/site-packages/aeosa')%0A# import appscript%0A
+See https://forum.sublimetext.com/t/dev-build-3156/33722/4%0A# This won't be necessary in the next build once the bug is fixed.%0Aclass FixedCommandPaletteInputSelectionCommand(sublime_plugin.WindowCommand):%0A    def run(self):%0A        self.window.run_command( %22show_overlay%22, %7B%22overlay%22: %22command_palette%22%7D )%0A        self.window.run_command( %22select_all%22 )%0A%0A%0A# Comment continuation%0Aclass SmartEnterCommand(sublime_plugin.TextCommand):%0A    def run(self, edit):%0A        stripped_line = self.view.substr(self.view.line(self.view.sel()%5B0%5D)).strip()%0A        cursor_char = self.view.substr(self.view.sel()%5B0%5D.end())%0A        to_insert = %22%5Cn%22%0A%0A        if stripped_line.startswith(%22#%22) and not stripped_line.startswith(%22#!%22):%0A            # Don't add a second comment char%0A            # (particularly important when the cursor is at the start of the line).%0A            if cursor_char != %22#%22:%0A                to_insert += %22# %22%0A        elif stripped_line.startswith(%22//%22):%0A            if cursor_char != %22/%22:%0A                to_insert += %22// %22%0A%0A        self.view.run_command(%22insert%22, %7B %22characters%22: to_insert %7D)%0A%0A# This is a replacement for the builtin copy and cut commands, which have annoying behavior%0A# when you invoke them with no selection: when you later go to paste that line, it will put%0A# it above whatever line you're on, *even if your cursor is not at the start of the line*.%0A# They do this by adding special metadata to the item in the clipboard that only they interpret,%0A# which means the special behavior only works in the same app, and you'd have no way of knowing%0A# what was different by looking at the plain text contents of the clipboard. That was a fun one%0A# to track down. See https://github.com/Microsoft/vscode/issues/16341%0Adef smart_clipboard(view, clipboard_command):%0A    sel = view.sel()%0A    if len(sel) == 1 and sel%5B0%5D.empty():%0A        orig = sel%5B0%5D%0A        view.run_command(%22expand_selection%22, %7B%22to%22: %22line%22%7D)%0A        view.run_command(clipboard_command)%0A        sel.clear()%0A        sel.add(orig)%0A    else:%0A        view.run_command(clipboard_command)%0A%0Aclass SmartCopy(sublime_plugin.TextCommand):%0A    def run(self, edit):%0A        smart_clipboard(self.view, %22copy%22)%0A%0Aclass SmartCut(sublime_plugin.TextCommand):%0A    def run(self, edit):%0A        smart_clipboard(self.view, %22cut%22)
 %0A

Fix various editing issues