Is there any way to not have the IDE's insertion handler for my completions?

The optimum solution for me would be one where I can use my own insert handler without the IDE inserting anything on completion.

One of the reasons for this is that Markdown completions make the most sense when not case sensitive, but the IDE tries to match case of inserted text to what is already there and it completely messes up the suggestions which are already case adjusted.

Right now I resort to replacing the IDE inserted text if the lookup item is not case sensitive.

I also want to leave auto-pop up suggestions on in plain text completions in my plugin but for touch typing and no syntax for guidance almost every word will match some suggestion, making touch typing impossible with on space completions. However, having the suggestions pop up is helpful and hitting tab or enter if desired.

If I could completely take over the insertion of text then I can kill two birds with one stone: prevent space char completions and insert exactly what is intended without having to remove the IDE inserted text first.

Official comment

In most cases, inserting a lookup string is part of what happens anyway during completion, so that's the default behavior. Removing the lookup string in the insert handler is quite rare (at least in our codebase), but it can be done in a single line: context.getDocument().deleteString(context.getStartOffset(), context.getTailOffset());

I'm not sure I fully understand the second part of your message. Selection by Space is only enabled with off-by-default completion setting. Even if it's enabled, you can still suppress it in places where you feel it's unnecessary by implementing a CharFilter.

Thank you Peter. The CharFilter is EXACTLY what I needed. JetBrains API is like magic. You just need to know the true name of something to be its master.

JetBrains IDEs are the best and for languages that have a syntax and semantics the and knowing what part of the API to use, usually results in a three-liner implementation. Markdown is not a real language and that causes some difficulties. Not the least of which is that I don't know the whole API or the correct use of it.

The second part was for space completions: I know that it is off by default but it applies to all completions in the IDE and no one (including myself) is willing to turn it off for all languages just to touch type in Markdown.

In places where plain text input is acceptable having auto-popup and space completions causes issues for touch typists. Having auto-popup is nice, however in these cases they should only be completed by tab or enter so that no unintentional completion gets in the way. I had user complaint about that and it has bothered me for quite a while.

The first part of removing/replacing is simple and how I do it now. I was only wondering if I was missing something.


Please sign in to leave a comment.