-
Notifications
You must be signed in to change notification settings - Fork 328
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(auto-edits): fix the partial decoration issue when not enough lines in the editor #6582
base: main
Are you sure you want to change the base?
Conversation
@@ -34,9 +60,6 @@ export class DefaultDecorator implements AutoEditsDecorator { | |||
before: { color: GHOST_TEXT_COLOR }, | |||
after: { color: GHOST_TEXT_COLOR }, | |||
}) | |||
this.hideRemainderDecorationType = vscode.window.createTextEditorDecorationType({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was redundant and was not getting used anywhere.
/** | ||
* Pre-computed information about diff decorations to be applied to lines in the editor | ||
*/ | ||
|
||
private diffDecorationInfo: DiffDecorationInfo | undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** | |
* Pre-computed information about diff decorations to be applied to lines in the editor | |
*/ | |
private diffDecorationInfo: DiffDecorationInfo | undefined | |
/** | |
* Pre-computed information about diff decorations to be applied to lines in the editor | |
*/ | |
private diffDecorationInfo: DiffDecorationInfo | undefined |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
this.decorator = null | ||
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add a new discardReason
and emit a discard event here:
this.decorator = null | |
return | |
this.decorator = null | |
autoeditAnalyticsLogger.markAsDiscarded({ | |
requestId, | |
discardReason: autoeditDiscardReason.noEnoughLines, | |
}) | |
return |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
if ( | ||
'decorationInfo' in request && | ||
request.decorationInfo && | ||
!this.decorator.canRenderDecoration(request.decorationInfo) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we untether this check from the decorator's instance so that we don't have to create and dispose of it later if we don't have enough lines?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah the flow doesn't look good that we only create decorator only to dispose it on some condition.
I though about it when first tried to implement this, As per the current implementation, the manager doesn't know the type of decorator it is using and canRenderDecoration
should be specific to a decorator, for example image renderer should have issues which our default renderer has, so making it a instance specific method seemed like the right call.
Please let me know if there are any alternate implementation ideas, would be happy to switch to them :)
b0fdfcc
to
4f6c6aa
Compare
@@ -86,7 +86,7 @@ const validRequestTransitions = { | |||
started: ['contextLoaded', 'discarded'], | |||
contextLoaded: ['loaded', 'discarded'], | |||
loaded: ['postProcessed', 'discarded'], | |||
postProcessed: ['suggested'], | |||
postProcessed: ['suggested', 'discarded'], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@valerybugakov added another transition state, since conflictingDecorations
and default-rendere
can discard.
Default auto-edits renderer can not render the decorations properly when there are not enough lines in the editor. The PR adds checks if the deocrator can render the decoration properly, and if it cannot do so we don't create any request for it.
Slack Context
Closes: https://linear.app/sourcegraph/issue/CODY-4656/handle-decorations-when-not-enough-lines-in-the-editor
Example from cody-chat-eval repo
Before (partial decoration rendered):
After (decorations will be discarded) - notice discard event on
cody by sourcegraph
Test plan
Tested on all the cody-chat-eval examples.