-
Notifications
You must be signed in to change notification settings - Fork 79
Fix peeked editor closing without reopening with new contents when triggered again at the same position in the same file #1019
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
Fix peeked editor closing without reopening with new contents when triggered again at the same position in the same file #1019
Conversation
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.
Nice fix! I only have a few comments about internal structure and documentation.
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.
Did you see the dummy peek window briefly flicker up or does it produce any scrolling to to the top of the file if position 1:1 is currently not in the viewport?
Also, I guess there is still a theoretical issue if you have a macro at 1:1 in the original source file and then invoke a nested expansion from there but I’d say it’s sufficiently unlikely that we don’t need to care about it because the source file probably needs to import the macro first and usually people write their import statements at the start of the file, which means that the macro can’t be at 1:1.
@ahoppen I don't see that flicker up since its fast, it doesn't scroll but jumps to 1:1 and then comes back to the macro expansion. People will notice something happened before the macro expansion is shown, but they won't notice what exactly happened since its fast. And, good catch with the issue on 1:1, I am aware of it and I was writing a fix for that. I do agree that its impossible to happen in most cases, but a preventive measure is still good. EDIT: Just fixed that 1:1 issue |
c5631ec
to
7c3e32c
Compare
@plemarquand I have updated it as you suggested. I am not sure if the explanation is too big, but I felt it was necessary. Please have a look and let me know if you have any other concerns. |
One thought that could allow us to avoid any scrolling: How about when we want to show a peek window at |
@ahoppen I got the same thought few hours back, got time now... will do that now. EDIT: |
…he same position in the same file
Changing the line might still result in a slight scroll if the expanded line is right at the start of the view port, I would imagine. If it’s possible to adjust the column, I would prefer that. If not, let’s go with your line proposal, it’s probably good enough. |
7c3e32c
to
998b0c8
Compare
I went with column one as you suggested and it works. 👍🏻 |
Ready to be merged, i guess? Happy that merging this will make all the work which we did to be usable by everyone (who's using |
While expanding nested macros, the peeked window is supposed to appear at the same position as the previous one. The "editor.action.peekLocations" command causes the previous peeked editor to close without reopening with the new contents if invoked at the same position in the same file.
This fixes the issue by having a workaround in which we open a dummy peeked editor so that the previous peeked editor is closed, followed by opening the actual peeked editor so that, we have the peeked editor to always display at the same position in the same file while expanding a macro.
This issue is not macro expansion specific and exists in general.
Semantic Functionality and nested macro expansions PR in sourcekit-lsp where the issue was faced initially: swiftlang/sourcekit-lsp#1634 + (#1017 or swiftlang/sourcekit-lsp#1636)
Expansion of Swift Macros in Visual Studio Code - Google Summer Of Code 2024
@lokesh-tr @ahoppen @adam-fowler