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 code completion override of home and end keys #71519

Merged

Conversation

adamscott
Copy link
Member

Changes the behaviour of the home and end keys when the autocomplete popup is open.

Rather than going to the top and the bottom of the list, home and end closes the autocomplete popup and work as usual.

Fixes #71471

@adamscott adamscott requested a review from a team as a code owner January 16, 2023 17:01
@KoBeWi KoBeWi added this to the 4.x milestone Jan 16, 2023
@adamscott adamscott force-pushed the fix-code-completion-home-end branch 2 times, most recently from 2bd0de4 to 560af4e Compare January 22, 2023 19:05
@adamscott adamscott requested a review from a team as a code owner January 22, 2023 19:05
@Paulb23
Copy link
Member

Paulb23 commented Jan 28, 2023

Checked a few other editors, this seems to be the common behaviour. Couple of unit tests are failing on macOS otherwise looks good.

@akien-mga akien-mga added the bug label Jan 28, 2023
@adamscott
Copy link
Member Author

I wonder if macOS has another behavior when using home and end keys.

@adamscott adamscott force-pushed the fix-code-completion-home-end branch 2 times, most recently from 6e52cc8 to 0a9474e Compare August 25, 2023 16:09
Copy link
Member

@groud groud left a comment

Choose a reason for hiding this comment

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

Approved in Input PR review

Edit: the failing check needs a fix first though.

@akien-mga akien-mga modified the milestones: 4.x, 4.2 Sep 19, 2023
@adamscott adamscott force-pushed the fix-code-completion-home-end branch 2 times, most recently from 14dd757 to ec5fafc Compare October 5, 2023 14:39
Copy link
Member

@Calinou Calinou left a comment

Choose a reason for hiding this comment

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

Tested locally (rebased on top of master d31794c), it works as expected.

simplescreenrecorder-2023-10-05_22.36.59.mp4

TIL pressing Home several times cycles between the beginning of the line with and without leading whitespace (like in VS Code) 🙂

An unit test needs to be fixed before this can be merged.

@adamscott
Copy link
Member Author

I installed a macOS virtual machine to test the issue (why-oh-why it doesn't pass the unit tests on macOS!?)

@bruvzg
Copy link
Member

bruvzg commented Oct 6, 2023

why-oh-why it doesn't pass the unit tests on macOS!?

I suspect it's related to SEND_GUI_ACTION("ui_end");, this macro is sending a key combination for the action (End key on all platforms). On other platforms, ui_text_caret_line_end is the same, but not on macOS (ui_text_caret_line_end is Command+Right and Ctrl+E).

@adamscott
Copy link
Member Author

why-oh-why it doesn't pass the unit tests on macOS!?

I suspect it's related to SEND_GUI_ACTION("ui_end");, this macro is sending a key combination for the action (End key on all platforms). On other platforms, ui_text_caret_line_end is the same, but not on macOS (ui_text_caret_line_end is Command+Right and Ctrl+E).

Yes. I just found out that by reading that Reddit comment.

@adamscott
Copy link
Member Author

adamscott commented Oct 6, 2023

I just added the same functionality for ui_text_caret_line_start and ui_text_caret_line_end and disabled the tests for ui_home and ui_end on macOS removed ui_home and ui_end.

Comment on lines 482 to 484
if (
k->is_action("ui_text_caret_line_start", true) ||
k->is_action("ui_text_caret_line_end", true)) {
Copy link
Member

Choose a reason for hiding this comment

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

I think it's more readable on a single line than on three like this (I know it's clang-format doing it but it makes it not worth it).

Copy link
Member Author

Choose a reason for hiding this comment

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

That's a left over of these being 4 checks instead of 2. I'm correcting this.

@akien-mga
Copy link
Member

Thanks!

@akien-mga akien-mga merged commit c6635b4 into godotengine:master Oct 9, 2023
15 checks passed
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.

Autocomplete hijacks home and end keys
7 participants