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

Fix Enter action will add incorrect number of newlines when triggered inside braces #3278

Merged
merged 4 commits into from
Aug 22, 2022

Conversation

andrewyuq
Copy link
Contributor

@andrewyuq andrewyuq commented Aug 19, 2022

  1. When enter action is triggered inside braces, an EnterBetweenBracesFinalHandler
    will be invoked which is an EnterHandlerDelegate, this delegate will call
    originalHandler.execute() to add an extra newline to correctly put the closing
    brace in another new line. Inside CodeWhispererEnterHandler we need to call
    originalHandler.execute() instead of super.executeWriteAction() to avoid
    adding another(3rd) newline character in the document.
  2. Since the originalHandler in EnterHandler is private not protected, need to
    make the originalHander in CodeWhispererEnterHandler a private field.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Description

Motivation and Context

Related Issue(s)

Testing

Added a test which will not pass before the fix but will pass after the fix.

Screenshots (if appropriate)

Checklist

  • I have read the README document
  • I have read the CONTRIBUTING document
  • Local run of gradlew check succeeds
  • My code follows the code style of this project
  • I have added tests to cover my changes
  • All new and existing tests passed
  • A short description of the change has been added to the CHANGELOG if change is customer facing in the IDE.

License

I confirm that my contribution is made under the terms of the Apache 2.0 license.

… inside braces

1. When enter action is triggered inside braces, an EnterBetweenBracesFinalHandler
will be invoked which is an EnterHandlerDelegate, this delegate will call
originalHandler.execute() to add an extra newline to correctly put the closing
brace in another new line. Inside CodeWhispererEnterHandler we need to call
originalHandler.execute() instead of super.executeWriteAction() to avoid
adding another(3rd) newline character in the document.
2. Since the originalHandler in EnterHandler is private not protected, need to
make the originalHander in CodeWhispererEnterHandler a private field.
@andrewyuq andrewyuq requested review from rli, Will-ShaoHua and a team August 19, 2022 21:28
@andrewyuq andrewyuq requested a review from a team as a code owner August 19, 2022 21:28
@andrewyuq andrewyuq changed the title Fix Enter action will add incorrect number of newlines when triggered inside braces [CodeWhisperer] Fix Enter action will add incorrect number of newlines when triggered inside braces Aug 19, 2022
@andrewyuq andrewyuq changed the title [CodeWhisperer] Fix Enter action will add incorrect number of newlines when triggered inside braces Fix Enter action will add incorrect number of newlines when triggered inside braces Aug 19, 2022
@rli
Copy link
Contributor

rli commented Aug 19, 2022

#3270

please include a changelog entry for this

@sonarqubecloud
Copy link

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 1 Code Smell

No Coverage information No Coverage information
0.1% 0.1% Duplication

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants