Inline Completion only when Enter is pressed

Answered

Hi,

I'm developing a plugin which make inline suggestions and I'm using the InlineCompletionProvider which is recommended in some posts here. I implemented successfully the extension point and my suggestion now is working. However, I want my suggestion to trigger only when the Enter key is pressed. How can I do this? I navigated the code until arrive to "InlineCompletionListeners.kt" which seems to there are already implemented some listeners to configure when the inline suggestion is fired, but I can't find how to use this or even is this what I'm looking for.

There is a method for only firing suggestions when Enter key is pressed or not?

Thank you and sorry for my bad english, 
Felip Yankovich

PDT: I'm using the DebouncedInlineCompletionProvider class for creating my custom suggestion class

0
3 comments

Hi Felip,

Inline completion is inserted on press of the key configured by a user. Why do you want to change the completion key to Enter in your plugin?

If your plugin had a different behavior, then it would break the IDE user experience, as your plugin behavior would be inconsistent with other inline completions. See https://plugins.jetbrains.com/docs/intellij/plugin-user-experience.html#consistent-behavior

0

```kotlin

override fun isEnabled(event: InlineCompletionEvent): Boolean {
  return  event is InlineCompletionEvent.DocumentChange && event.typing is TypingEvent.NewLine 
}```

0

Hi!

Thank you so much for this! 

0

Please sign in to leave a comment.