Skip to content

In VSCode extension added user configuration for commit characters for accepting code suggestions#8515

Merged
lahodaj merged 1 commit intoapache:masterfrom
Achal1607:user-config-code-commit
Jul 4, 2025
Merged

In VSCode extension added user configuration for commit characters for accepting code suggestions#8515
lahodaj merged 1 commit intoapache:masterfrom
Achal1607:user-config-code-commit

Conversation

@Achal1607
Copy link
Collaborator

This PR adds support for configurable commit characters in the Java LSP server. Users can now define which characters (e.g., ., ,) trigger the acceptance of a code completion suggestion via the new netbeans.java.completion.commit.chars setting in the Netbeans VS Code extension. The server reads this configuration and applies the characters to completion items dynamically. This improves the flexibility and user control over the code completion behaviour.

@Achal1607 Achal1607 requested review from dbalek, lahodaj and sdedic May 21, 2025 10:27
@Achal1607 Achal1607 added Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) LSP [ci] enable Language Server Protocol tests VSCode Extension labels May 21, 2025
@apache apache locked and limited conversation to collaborators May 22, 2025
@apache apache unlocked this conversation May 22, 2025
@lahodaj
Copy link
Contributor

lahodaj commented May 22, 2025

Not sure what @dbalek thinks here, but thinking of this for a bit: I am not sure that forcing the same list of commit characters on all completion items is ideal. E.g. there may be some items where it may make sense to confirm them on (, while some not, and that is not possible to do with a single list.

Maybe one of these would work better:

  • have a boolean switch that would enable/disable the commit characters that the provider filled in. I.e. if enabled, whatever commit character that the provider filled in the item would be used; if disabled, none would be used.
  • have a setting with permitted commit characters. I.e. the real commit characters in an item would be the intersection between this setting and the characters from the provider. (Or, the setting could be a deny list - i.e. the characters in the list would be removed from every item's commit characters.)

@Achal1607 Achal1607 added this to the NB27 milestone May 23, 2025
@lahodaj
Copy link
Contributor

lahodaj commented Jun 12, 2025

Going back to this - thinking of this more, the actual commit characters sent out from the server should probably be an intersection between the commit characters requested by the completion item, and the user-selected commit characters. That would make most sense to me.

@dbalek
Copy link
Contributor

dbalek commented Jun 12, 2025

Going back to this - thinking of this more, the actual commit characters sent out from the server should probably be an intersection between the commit characters requested by the completion item, and the user-selected commit characters. That would make most sense to me.

Yes, this approach would be better, however even in NetBeans, all JavaCompletionItems currently share the same list of commit characters (even though the API would allow more fine grained approach). Would be a nice enhancement.

@lahodaj
Copy link
Contributor

lahodaj commented Jun 30, 2025

I was digging a little bit more on how this works in NetBeans, and it turns out that whatever is in the settings is used unconditionally for all completion items, except for ( for a very specific list of completion items (MethodItem, etc.).

So, ultimately, we can go with the patch as proposed here, I think.

Copy link
Contributor

@lahodaj lahodaj left a comment

Choose a reason for hiding this comment

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

Looks OK to me.

@lahodaj
Copy link
Contributor

lahodaj commented Jun 30, 2025

FWIW, the existing filter is here:

if (evt.getKeyChar() == '(' && !(this instanceof AnnotationItem)

@lahodaj
Copy link
Contributor

lahodaj commented Jul 2, 2025

Unless there are objections, I would like to integrate in a few days.

@lahodaj lahodaj merged commit dbfe63d into apache:master Jul 4, 2025
67 of 68 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Java [ci] enable extra Java tests (java.completion, java.source.base, java.hints, refactoring.java, form) LSP [ci] enable Language Server Protocol tests VSCode Extension

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants