Skip to content

ContentAssistProcessor no longer activated when CTRL key is pressed #2723

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

Open
2 tasks done
ptziegler opened this issue Jan 17, 2025 · 1 comment · May be fixed by #2838
Open
2 tasks done

ContentAssistProcessor no longer activated when CTRL key is pressed #2723

ptziegler opened this issue Jan 17, 2025 · 1 comment · May be fixed by #2838
Labels
bug Something isn't working

Comments

@ptziegler
Copy link
Contributor

Let's make sure issue is not already fixed in latest builds first.

Steps to reproduce

  • Create a custom source viewer with a default ContentAssist.
  • Register a custom ContentAssistProcessor that is automatically activated when pressing space.
  • Activate the processor by pressing CTRL+Space

I expected: The processor to be activated

But got: The processor remains inactive

Tested under this environment:

  • Windows 11
  • Eclipse 2024-12

Workaround

ContentAssistant assistant = new ContentAssistant() {
    @Override
    protected AutoAssistListener createAutoAssistListener() {
        return new AutoAssistListener() {
            @Override
            public void keyPressed(KeyEvent e) {
                if (e.stateMask == SWT.CONTROL) {
                    e.stateMask = 0;
                }
                super.keyPressed(e);
            }
        };
    }
};

Community

  • I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.

This is a result of #1556 in an attempt to fix #891. As part of this change, any events where the CTRL key is pressed will no longer activate the content processor.

In hindsight, I wonder if it would've been a better approach to create a subclass for the AutoAssistListeners and use it wherever state masks are undesirable.

@ptziegler ptziegler added the bug Something isn't working label Jan 17, 2025
@ptziegler
Copy link
Contributor Author

As far as I understand the initial bug, the issue was reported for the Java editor. My proposal is to push this restriction to the JavaSourceViewerConfiguration by subclassing the ContentAssistant there and then reverting aa42db1.

ptziegler pushed a commit to ptziegler/eclipse.jdt.ui that referenced this issue Mar 14, 2025
On some versions of MacOS, the Ctrl+S hotkey is realized as a key event
with 'S' as character and 'Ctrl' as state mask, rather than the 'XOFF'
character (0x13, also with the 'Ctrl' state mask).

If the auto-activation trigger for Java include the character 's', this
then causes the completion box to show up when the user tries to save
the editor while it's already in a clean state.

This was previously fixed on the platform [1], but needs to be reverted
as generic source viewers might also check for the 'Ctrl' key [2]. In
order to avoid a regression, the check therefore needs to be moved to
the JDT component.

[1] eclipse-platform/eclipse.platform.ui#1556
[2] eclipse-platform/eclipse.platform.ui#2723
ptziegler added a commit to ptziegler/eclipse.jdt.ui that referenced this issue Mar 14, 2025
On some versions of MacOS, the Ctrl+S hotkey is realized as a key event
with 'S' as character and 'Ctrl' as state mask, rather than the 'XOFF'
character (0x13, also with the 'Ctrl' state mask).

If the auto-activation trigger for Java include the character 's', this
then causes the completion box to show up when the user tries to save
the editor while it's already in a clean state.

This was previously fixed on the platform [1], but needs to be reverted
as generic source viewers might also check for the 'Ctrl' key [2]. In
order to avoid a regression, the check therefore needs to be moved to
the JDT component.

[1] eclipse-platform/eclipse.platform.ui#1556
[2] eclipse-platform/eclipse.platform.ui#2723
ptziegler added a commit to ptziegler/eclipse.platform.ui that referenced this issue Mar 14, 2025
This reverts commit aa42db1, as the
change has to be done on the JDT side [1].

[1] eclipse-jdt/eclipse.jdt.ui#2086

Closes eclipse-platform#2723
ptziegler added a commit to ptziegler/eclipse.platform.ui that referenced this issue Mar 17, 2025
This reverts commit aa42db1, as the
change has to be done on the JDT side [1].

[1] eclipse-jdt/eclipse.jdt.ui#2086

Closes eclipse-platform#2723
ptziegler added a commit to ptziegler/eclipse.jdt.ui that referenced this issue Mar 25, 2025
On some versions of MacOS, the Ctrl+S hotkey is realized as a key event
with 'S' as character and 'Ctrl' as state mask, rather than the 'XOFF'
character (0x13, also with the 'Ctrl' state mask).

If the auto-activation trigger for Java include the character 's', this
then causes the completion box to show up when the user tries to save
the editor while it's already in a clean state.

This was previously fixed on the platform [1], but needs to be reverted
as generic source viewers might also check for the 'Ctrl' key [2]. In
order to avoid a regression, the check therefore needs to be moved to
the JDT component.

[1] eclipse-platform/eclipse.platform.ui#1556
[2] eclipse-platform/eclipse.platform.ui#2723
ptziegler added a commit to ptziegler/eclipse.platform.ui that referenced this issue Mar 25, 2025
This reverts commit aa42db1, as the
change has to be done on the JDT side [1].

[1] eclipse-jdt/eclipse.jdt.ui#2086

Closes eclipse-platform#2723
ptziegler added a commit to ptziegler/eclipse.jdt.ui that referenced this issue Apr 9, 2025
On some versions of MacOS, the Ctrl+S hotkey is realized as a key event
with 'S' as character and 'Ctrl' as state mask, rather than the 'XOFF'
character (0x13, also with the 'Ctrl' state mask).

If the auto-activation trigger for Java include the character 's', this
then causes the completion box to show up when the user tries to save
the editor while it's already in a clean state.

This was previously fixed on the platform [1], but needs to be reverted
as generic source viewers might also check for the 'Ctrl' key [2]. In
order to avoid a regression, the check therefore needs to be moved to
the JDT component.

[1] eclipse-platform/eclipse.platform.ui#1556
[2] eclipse-platform/eclipse.platform.ui#2723
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant