Conversation
This reverts commit b0058d1.
|
Hey again @pkukielka :D looks like you worked on this section as well. I'm looking for another review. |
Hey @justinmilner1 , thanks for looking into this! I think it is good place to fix it but small correction may be needed. There might be a situation, where multiline completion is indeed blank, but single line is not. if (text.isBlank()) {
if (!startsInline) {
logger.warn("autocomplete returned blank suggestions")
return
}
} else {
val renderer = CodyAutocompleteBlockElementRenderer(text, items, editor)
val inlay2 =
inlayModel.addBlockElement(
/* offset = */ cursorOffset,
/* relatesToPrecedingText = */ true,
/* showAbove = */ false,
/* priority = */ Int.MAX_VALUE,
/* renderer = */ renderer)
if (inlay == null) {
inlay = inlay2
}
}It starts to be a bit convoluted. |
|
@pkukielka Just pushed a commit with a draft of the consolidated renderers and simplified logic in the manager. |
|
@pkukielka Just did some more manual testing, and I don't see any affected automated tests, so I think it is ready for review |
|
@pkukielka Bumping this |
dominiccooney
left a comment
There was a problem hiding this comment.
It may make sense to keep the Element/BlockElement/SingleLine classes, but clean them up (specifically, naming: SingleLine/Multiline, or BlockElement/InlineElement, instead of two different domains like SingleLine/BlockElement; and push the single line width calculations down to the single line class and leave it abstract in Element...)
If not, do we need CodyAutocompleteElementRenderer now, why not fold it all into CodyAutocompleteRenderer?
| val rendererType = if (startsInline) AutocompleteRendererType.INLINE else AutocompleteRendererType.BLOCK | ||
| val renderer = CodyAutocompleteRenderer(completionText, items, editor, rendererType) | ||
|
|
||
| val inlay = if (startsInline) { |
There was a problem hiding this comment.
Should we move this to the CodyAutocompleteRenderer?
Or at the very least, we could look at something like renderer.type instead of the startsInline we're hanging on to.
|
|
||
| val inlay = if (startsInline) { | ||
| inlayModel.addInlineElement(cursorOffset, /* relatesToPrecedingText = */ true, renderer) | ||
| } else { |
There was a problem hiding this comment.
Hey, sorry for the long delay.
I'm not sure this is correct.
Multiline autocompletion can start inline, but then continue to the other lines.
So in fact 3 states are possible:
- single inline autocompletion ('addInlineElement')
- multiline completion which starts bellow current line (
addBlockElement) - multiline completion which starts inline but also continues to the other lines (
addInlineElement+addBlockElement)
Fixes #1909
Could not replicate the issue, but based on the stack trace it looks like a blank text value was making its way through this pathway.
I've added a check immediately prior to the instantiation of the renderer to prevent this.
It's possible the issue was arising from the line immediately above:
val text = (if (startsInline) lines.drop(1) else lines).dropWhile { it.isBlank() }.joinToString("\n")Test plan
I ran the extension and verified via logging that the block was being executed as expected with autocomplete.