-
Notifications
You must be signed in to change notification settings - Fork 29.3k
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
Feature #94173: Scroll when inserting suggestion #94327
Feature #94173: Scroll when inserting suggestion #94327
Conversation
@@ -273,6 +273,9 @@ export class SuggestController implements IEditorContribution { | |||
// keep item in memory | |||
this._memoryService.memorize(model, this.editor.getPosition(), item); | |||
|
|||
// keep line number for scrolling | |||
const initialLineNumber = this.editor.getPosition().lineNumber; |
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.
You should be using this StableEditorScrollState
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.
@jrieken
Thanks for your review. I've update the PR.
fed8165
to
8a4b4e9
Compare
Adding @alexdima to review the changes in the scroll state. Tested this, it kinda works. When inserting import-completion by current line doesn't move anymore, but when undoing it seems to shift up and that's not nice |
@jrieken |
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.
LGTM, except the pushUndoStop
call in restoreRelativeVerticalPositionOfCursor
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.
There is still a call to editor.pushUndoStop
in restoreRelativeVerticalPositionOfCursor
. It needs to be removed from there, as restoring the scrolling position should not affect the undo stack in any way.
@alexdima |
@@ -290,6 +293,9 @@ export class SuggestController implements IEditorContribution { | |||
adjustWhitespace: !(suggestion.insertTextRules! & CompletionItemInsertTextRule.KeepWhitespace) | |||
}); | |||
|
|||
scrollState.restoreRelativeVerticalPositionOfCursor(this.editor); | |||
this.editor.pushUndoStop(); |
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.
Why are you adding an undo-stop at all?
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.
@jrieken
I'm sorry, I misunderstood. I'll remove it.
The scroll jump after undo still happens (#94327 (comment)). Adding another undo-stop is not the right approach here but I also don't know what to do. @alexdima can you advice? We now control the scroll state when doing the suggest edits but I don't thing we have a say when undoing these changes. |
Effectively, when doing and inserting an import, the editor is scrolled down by 1 line ( The undo does not capture the That is just how undo/redo works currently, and is not 100% awesome for this specific case, and we can make new issues about that if we want to, but I don't know how to tackle it, nor do I think that it should block this PR... |
This PR fixes #94173