Dev Build 3155 is out now at https://www.sublimetext.com/3dev with various improvements to the Command Palette
Dev Build 3155
Ah, the unfocus/re-focus command palette bug is still there :s
Also: did the fuzzy algo change in the recent versions? I feel like this shouldn’t be the first match:
A few more details:
-
.sublime-syntax
files now fully supportwith_prototype
being applied toembed
actions - The escape pattern bug with the embed action was triggered when the embedded syntax popped before an escape token was found
- The preview text for command palette input is based on the text size and color of
quick_panel_label
- The width of the command palette and quick panels is using an algorithm similar to build 3153, but with a slightly wider minimum
- Restored functionality where the command palette would remember previous choice for given input
- The up and down keys should no longer change the text selection in the command palette
- Added support for the
move
,select
andcancel
command to the command palette - When running
show_overlay
, an arg namedcommand
may be passed to automatically select the command and enter input mode - If a command that accepts input is invoked without one of the necessary args, and it exists in the command palette, the command palette will be opened and the
input()
method of the command will be executed to create the necessary input handler. - Fixed support for the
content_margin
onoverlay_control
- Updated
Theme - Default
to use.hidden-color-scheme
instead of.tmTheme
for easier user overrides of Widget colors - The
settings.py
EventListener
was rewritten to aViewEventListener
It looks like using the arrow keys while a text input handler is allowing you to enter input causes Sublime to crash. This seems to be the case whether there is any text present or not. This is most easily replicated out of the box by selecting the Arithmetic
command and then pressing the up arrow.
I can reproduce OdatNurd’s issue on Win10 Pro x64 1709 with the 64bit portable 3155.
I’m noticing that when you do this, the input()
method gets invoked twice. For example, given this command:
class ExampleTextCommand(sublime_plugin.TextCommand):
def run(self, edit, text):
self.view.insert(edit, 0, text)
def input(self, args):
print("input(%s)" % args)
return sublime_plugin.TextInputHandler()
Running the command from the console or from a key binding executes the input()
method twice, with it being None
the first time through:
>>> view.run_command("example_text")
input(None)
input({})
If the command is invoked from a menu item, it executes twice but passes an empty dictionary both times.
Is this something that’s expected? It doesn’t get executed twice if you run the command directly from the command palette.
It may also be worth noting that sometimes in the specific case of running this command via the console, when you finish entering the text and the command runs, it gets inserted into the console input widget. That doesn’t happen if you run it via a key binding or a menu item. I haven’t determined a way to reliably reproduce this particular issue, though.
Modifying the run
method to get the active view from the window inserts into the buffer, though:
def run(self, edit, text):
self.view.window().active_view().insert(edit, 0, text)
Help on TextInputHandler
Binding the show_overlay
command with the text
arg still selects all the inserted text when opened.
{ "keys": ["ctrl+alt+s"], "command": "show_overlay",
"args": {"overlay": "command_palette", "text": "Set Syntax: "} },
This is pretty annoying for bindings like the above.
Here’s a video of it happening.
I invoke it with the keyboard, then focus the view/buffer behind with the mouse, then refocus the palette using the keyboard shortcut. Then, you don’t even see the cursor in the palette’s textarea. If you try to type some keys, you will see nothing happening. But if you re-open it, you will see what you typed previously and the textarea will still seem frozen, ie. no cursor displayed, no new keystroke appearing.
Also, in the video, you can see that the palette moves like 1 pixel to the left every time I open it and then begin typing.
That is correct. The first time it is called to see if the command will return an input handler. If not, the command palette will not be used. We don’t want to open the command palette unless we know it will be used.
If it does handle input and is present in the command palette list of commands, then we invoke the command palette and tell it to pre-select the command with the args that have been provided. Those are then passed to create the actual input handler that it used to prompt the user for the remaining input.
It sounds like we are being a little inconsistent in that the console invocation is passing None
the first time.
In terms of the text command being invoked on the console input text area, I’m not sure if I’d consider that a bug or not. I suppose that it only happens sometime is a bug, but in general I would expect that text commands should apply to pretty much any text area.
There is a standalone .tar.bz2
that I will document the location of today. I’ll be working on getting it set up to run via Travis CI for pull requests on https://github.com/sublimehq/Packages. The syntax test runner is only available for Linux x64. If you create a Data
folder next to the executable and extract the Packages
repo inside of Data/
, then it will find those when you invoke ./syntax_tests
.
A few diagnostic messages are printed to stdout, but any other output from the executable is written to stderr. This includes assertion failures, warnings and errors. If anything is written to stderr, the executable will set the return code to 1
to signal a failure.
I can confirm that this fixed the issue I was having with the template syntax. Thanks a lot!
I would still have to trigger sublime commands that use the new InputHandler classes with run_command
, keyboard shortcuts etc!
For example, window.run_command("rename_file", {'new_name': "test.py"})
works as expected but window.run_command("rename_file")
throws an error: missing 1 required positional argument: 'new_name'
window.run_command("rename_file")
should open the input dialog. That would make the new API more useful.
It will, if the command defines an input()
method that generates an input handler, and the command is listed in the command palette.
I just tested this out. The issue is that when invoked from the command palette build 3155 passes args as None
when checking to see if the command handles input, which breaks the line if "new_name" not in args:
. I’ll get this fixed for the next build.
I’ve gotten the arrow key bug, text preselection and None
args bugs fixed. I am looking into the focus issue right now.