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

Bracket matching #50

Merged
merged 25 commits into from
Oct 4, 2024
Merged

Bracket matching #50

merged 25 commits into from
Oct 4, 2024

Conversation

dingfeli
Copy link
Contributor

@dingfeli dingfeli commented Oct 3, 2024

Issue #, if available:
https://issues.amazon.com/issues/ECLIPSE-286

Premise

This PR revamps the rendering logic for the suggestion text, using the change in #37 as foundation. It also enables bracket matching during typeahead.

Description of changes:

  • Separates each line in the suggestion texts to be rendered individually. This simplifies the top level rendering logic in renderer listener.
  • Disables auto closing of brackets (this also includes strings) during typehead. This is done to aid bracket matching by highlighting the corresponding closing brackets as user types over an open bracket. The auto closing brackets that should have been added as user buffer during the typeahead would then be added after the preview ends.
  • An addition of a workbench listener to revert aforementioned settings back to what they were prior to workbench shutdown. This is done to prevent a persistent change of bracket related user settings should users quit eclipse while the preview is still active.

Apart from the features addition, there are also the following bug fixes:

  • Fixes IDE induced caret "jumps" terminating preview prematurely.
  • Fixes typeahead deadreckoning becoming out of sync when user backspaces more than one character at a time.
  • Deduplicates partially typed suggestion when user accepts answer after having typed ahead.

Test

Closing brackets are being highlighted during typeahead:
bracket_highlight

Unresolved brackets are added to user buffer upon preview termination:
bracket_persists

Disclaimer

There are still some edge cases that we would need to cover in the future with more changes.
Most of these have to do with the differences between how the lsp and the IDE interprets whitespace.

For example, consider the following text:

1. public static void main(String[] args) {
2.     int x = 1;
3. 
4.     int y = 2;
5. }

Currently is it possible that the user may not be able to typeahead across line 3. This is because the suggestion on from line 2 to line 3 may very well be \n or \n\t or \n or \n\n.
For reference, depending on the IDE's settings, when user types from line 2 to 3, the input as observed by verifyText is going to be either \n\t if they have tabs only enabled or \n ' ' ** $tabSize if they have space only enabled.

I have made an issue to track these: https://issues.amazon.com/issues/ECLIPSE-340

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

}
}
break;
case NADA:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This made me chuckle..but maybe NONE? 😄

@dingfeli dingfeli merged commit cc12271 into main Oct 4, 2024
1 check passed
@dingfeli dingfeli deleted the bracket-matching branch October 4, 2024 00:33
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.

2 participants