Skip to content
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

221 pressing tab on context selector duplicates the subsequent text if it exists #224

Conversation

dogusata
Copy link
Collaborator

@dogusata dogusata commented Jan 16, 2025

Problem

  • When tab is changed or in VSCode Q panel gets closed and opened back, scroll position randomly changes
  • When context selector panel is opened (hitting @) if the next character on the cursor position is not a space or end of line filtering doesn't work and if user hits enter | tab | space it duplicates the next word available.

Solution

Scroll position misbehaviors:

When VSCode hides an extension panel, it shrinks the width and height of it to 0. And since the container size also shrinks down, it was setting the scroll position to an unexpected one. We added a ROOT_RESIZE global event and the handler for it in the ChatWrapper to understand if the root element size goes under 10px width or 10px height when that tab is active. When root elm gets resized back (more than 10px width and height but only once until the next lower than 10px), we're setting the scroll position back to the latest recorded before the hide precedure.
The same applies for the tab switches. When a tab is deselected, it looses height and width which causes scroll position to go to a random value. We added a new subscription on tab store model called beforeTabChange and in the handler we're recording the last scroll position. When the tab get selected back we're resetting the scroll position to the latest recorded.

Context selector misbehaviors:

As user types after opening the context selector, the filtering was checking the written text from the cursor start to next space or line end character not what the actual cursor goes. Now it checks depending on the cursor position. So as user types filtering matches what user types instead of trying to match the whole word starting from the init cursor index. When user hits tab, space or enter, it only adds the matching context item. If there is no context item in the filtered view, it just leaves it as is.

Tests

  • I have tested this change on VSCode
  • I have tested this change on JetBrains

License

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

Sorry, something went wrong.

As user types after opening the context selector, the filtering was checking the written text from the cursor start to next space or line end character not what the actual cursor goes.
When VSCode hides the extension, it shrinks the width and height to 0. And since the container size also shrinks down, it was rescrolling to an unexpected position. Added resize global event and handler in chatwrapper to undertand if the root element size goes under 10px width or 10px height. When root elm gets resized back (more than 10px width and height for the first time), we're setting the scroll position back to the latest.
The same applies for the tab switches. When a tab is switched, it looses height and width which causes scroll position to go to a random value. We added a new subscription called beforeTabChange which records the last scroll position and sets it back when the tab is selected back
@dogusata dogusata requested a review from a team as a code owner January 16, 2025 16:42
Since the old structure was broken to keep the scroll position consistent, the snapshots are aslo updated to match the fixed one
Jurredr
Jurredr previously approved these changes Jan 17, 2025
Added more update mechanism like wheel, animationend etc. to record the last scroll position as it is updated, since the scrollPos already being updated (undesired value) when the resize event triggered.
Jurredr
Jurredr previously approved these changes Jan 17, 2025
@Jurredr Jurredr merged commit cce7cb7 into main Jan 17, 2025
5 checks passed
@Jurredr Jurredr deleted the 221-pressing-tab-on-context-selector-duplicates-the-subsequent-text-if-it-exists branch January 17, 2025 12:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Pressing tab on Context selector duplicates the subsequent text if it exists
2 participants