Improvements and bugfixes to autocompletion
Ok, here's a last one for your perusal. :) @gabrielabittencourt submitted her awesome autocomplete feature (!808 (merged)) in GSoC 2021. As is so often the case in GSoC projects, there were still a few minor quibbles which she didn't have the time to address. I was hoping that we could work on this some more in this years' GSoC, but it appears that she is simply too busy with other things right now.
So here's my attempt at fixing what I consider the most important issues. This is based on my students' and my own experiences after using the new feature for a year. Specifically, this MR addresses the following:
-
If autocompletion is enabled, make sure that the help index updates are performed in a timely manner. Previously the completions might be out of date or completely unavailable. This is because for technical reasons (speed, mostly), completion index generation is tied in with help index generation, so if the latter was out of date or non-existent, because the user didn't invoke the help browser, so was the former. This MR fixes that. The generation process now also properly deals with some special "umbrella" help patches which have the actual object names in the NAME field of the META data. E.g., my pet peeve there was
adc~_dac~-help.pd
which would show as an actual object nameadc~_dac~
in the completion; this is now fixed. -
Tab now cycles through all the completions in the autocompletion dropdown (similar to how autocompletion works in fish or emacs autocompletion mode), and all the different ways to initiate a completion (Tab, Return and mouse clicks in the autocompletion dropdown) work consistently. After a completion, the caret is positioned at the end of the textbox so that the user can start typing arguments.
-
There's a new keyboard command (ctrl+y) which let's you "yank" (remove) an existing completion, for both object names and specific parameter completions. E.g., assume that you still have the bogus
adc~_dac~
completion in your completion index, or a combination of parameters for an object that you want to get rid of, such asdac~ 1 3 2 4
. Then you can now just type or complete that text, press ctrl+y twice (the second time is for confirmation, any other key will abort the operation), and away it goes. Note that this decidedly uses a "low-tech", non-GUI keyboard interface with some helpful prompts in the Pd console. This is just quicker than having to get your hands off the keyboard and operate some fancy buttons, say, in the autocomplete menu. It also was much easier to implement. We might still revisit this at a later time if Gabriela ever gets working on the feature again, but that's what we have for now. -
I also added a binding for the Esc key which just makes the autocomplete popup go away until you start typing again. I find this convenient, e.g., if the popup obscures some part of the patch that I'd like to see without having to stop editing.
I already tested this on Linux and Windows, Mac will be next, and then I'll throw it up on the OBS. In the meantime, if you have any ideas or comments, please let me know.