-
Notifications
You must be signed in to change notification settings - Fork 91
Update module completion return statement to support FQCN #57
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I actually really like the way it currently behaves, so that even if the FQCNs are best practice and should be placed in code, the user can just focus on writing the name of the actual component that he uses. And since that is a matter of personal preference, I'd suggest implementing a feature toggle (setting) for that.
@tomaciazek We do want to encourage the use of full names, and the toggle is still there. I'm not sure I understand your remark here... Are you suggesting an additional toggle after this goes in? |
If logic autocomplete no longer works when trying to type builtin modules without prefix I would be against this change. While I am totally ok to always put the FQCN inside the files, I do also think that when using auto-complete our language server should be smart-enough to make the builtin implicit and add it when user presses enter. Example, typing "deb" should autocomplete with I still need to compile it locally and test it myself. |
|
I'm not against full names, that default is already changed and the user will get FQCN with autocomplete. This PR, however, changes the sorting and filtering, so that collection namespaces and collection names will be matched and displayed first. @priyamsahoo, your example is misleading - it only shows built-in The new toggle I propose would be to influence this sorting/filtering behavior. |
I have updated the priority and kept the name in the first priority even when the useFQCN is set to true. |
Also, I am linking a new issue (a feature to add on) that I created to support config options to set priorities (for filtration of suggestions in module FQCN auto-completions) if the user wishes to. Issue: ansible/vscode-ansible#1146 |
@tomaciazek is the new version ok now? If so, please remove the requested changes so we can merge it. |
? `${priority}_${moduleFqcn}` | ||
: `${priority}_${name}`, | ||
filterText: useFqcn | ||
? `${name} ${moduleFqcn} ${collection} ${namespace}` // name should have highest priority (in case of FQCN) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we need that ternary here at all? collection
and namespace
are anyway part of moduleFqcn
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ternary is needed because when the user opts for suggestions based on FQCN, he/she should be able to prioritize the filtration (which is something we will be working post this: #62).
Also, filtration based on moduleFQCN whole together and filtration based on collection and namespace separately would have different behaviors and user should have control over it (since we decided to give that option).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the user types in debug
, ${name}
will be matched. If they type ansible.builtin.debug
, ${moduleFqcn}
will be matched. I don't see a useful scenario in which ${collection} ${namespace}
would be matched... unless it is an attempt to force a longer partial match (with duplicates) to elevate the entry on the sorted list. Is it?
|
I agree it was there. I was a little wrong with my words. Let me re-iterate: "With the current changes, the user now would be able to see the FQCN filtration in a more pronominal way, which in tern, would help the user to provide right set of characters, for a right suggestion" Other than this, the PR contains additional changes to enhance the user experience for auto-completions based on module FQCN. Before: With current change: |
Raised an issue to track configuring sort order ansible/vscode-ansible#1150 |
The PR has the logic to support FQCN in module auto-completion. Whenever
useFullyQualifiedCollectionName
is set to true (which by-default is), the user will get auto-completions for module names based on their FQCN.For e.g., writing
ansible.builtin
would give suggestions for all the modules that are under the ansible.builtin collection namespace.The auto-completion is smart enough to understand shortcuts while writing module names and provides the correct auto-completion accordingly.
For e.g., writing
ansiping
(or something similar) would give youansible.builtin.ping
as the first suggestion. Similarly, writingiosping
(or similar) woould give youcisco.ios.ping
as the first suggestion.Resolves [ansible-language-server] Add task completion name to work with collection completions. vscode-ansible#145