How to suppress the postfix template autocomplete popup when a full stop is typed after part of a live template key?

Environment

The TeXiFy-IDEA plugin for the LaTeX language. For this case, it is relevant that parts of live template keys can be actual words which users type in text.
Original issue report: https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/1500

Issue description

We have a live template with key itm which is present by default. We also have postfix templates, for which autocompletion is triggered when typing a full stop (in fact, we wanted to change this, which would also solve the problem, but it does not appear to be configurable).

However, when typing the end of a sentence, ending with typing <full stop><enter> we do always want a newline to be inserted and not a postfix template, because postfix templates should not get in the way of typing sentences like you normally would.
We solved this by overriding TypedHandlerDelegate#checkAutoPopup, such that it returns Result.STOP when charTyped == '.' and this works.

However, the problem is not solved completely: when the user types a part of a live template key and then a full stop, so for example it. then the live template autocompletion will pop up on typing it, but it will remain there even when we return Result.STOP when the full stop is typed, thus the postfix template completion will be shown and will require the user to press escape before being able to insert a newline with <enter>.

Are we wrong to expect the autocompletion popup to disappear on Result.STOP, and what could be a proper solution?

Things I have thought of, but I did not manage to work out:

  • Use a different symbol than full stop for triggering postfix completion (preferably not because consistency, but if necessary acceptable)
  • Suppress the autocomplete popup in a different place than the TypedHandler
  • Changing all the live template keys such that no English words are contained in them (sounds like a bad idea)
  • Disabling live templates entirely (sounds like an overkill bad idea)

checkAutoPopup implementation: https://github.com/Hannah-Sten/TeXiFy-IDEA/blob/80ca58dbfd0bb3f0bffe16888955479e37970993/src/nl/hannahsten/texifyidea/highlighting/LatexTypedHandler.kt#L86

0

Please sign in to leave a comment.