ansible / vscode-ansible

vscode/vscodium extension for providing Ansible auto-completion and integrating quality assurance tools like ansible-lint, ansible syntax check, yamllint, molecule and ansible-test.
https://ansible.readthedocs.io/projects/vscode-ansible/
MIT License
360 stars 87 forks source link

Extension incorrectly considers colon as part of a word #953

Open kassi opened 1 year ago

kassi commented 1 year ago

Summary

When I click on a yaml key, the whole word including the colon is highlighted and used as the "word".

Colon should not be part of the word. When I now perform the action to "Search in Dash for current selection" for instance, it searches for the key including colon, which won't reveal anything. One has to manually remove the colon from the search term and search again.

I also tried to overwrite wordSeparators in the settings with

{
  "[ansible]": {
    "editor.wordSeparators": "`~!@#%^&*()=+[{]}\\|;:'\",.<>/?"
  }
}

but this is obviously not considered, since it still includes the dot (which is correct in this case), which I incorrectly left in the separators list above.

Extension version

v2.5.86

VS Code version

1.80.1

Ansible Version

ansible [core 2.15.2]
  config file = /Users/Kassi/Projects/Servers/vserver/ansible.cfg
  configured module search path = ['/Users/Kassi/.ansible/plugins/modules', '/usr/share/ansible/plugins/modules']
  ansible python module location = /opt/homebrew/Cellar/ansible/8.2.0_1/libexec/lib/python3.11/site-packages/ansible
  ansible collection location = /Users/Kassi/.ansible/collections:/usr/share/ansible/collections
  executable location = /opt/homebrew/bin/ansible
  python version = 3.11.4 (main, Jun 20 2023, 17:23:00) [Clang 14.0.3 (clang-1403.0.22.14.1)] (/opt/homebrew/Cellar/ansible/8.2.0_1/libexec/bin/python3.11)
  jinja version = 3.1.2
  libyaml = True

OS / Environment

MacOS Ventura 13.5, ansible-lint 6.17.2 using ansible-core:2.15.2 ansible-compat:4.1.5 ruamel-yaml:0.17.32 ruamel-yaml-clib:0.2.7

Relevant log output

No response

priyamsahoo commented 1 year ago

I tested it, and it seems working fine with the latest release. Is it possible to send a screen recording of the issue?

kassi commented 1 year ago

Sure. Hope it helps. https://github.com/ansible/vscode-ansible/assets/993392/fc0ffbca-0963-4975-a425-d923d5a4d325

kassi commented 1 year ago

BTW I also updated to v2.6.92 with the same effect. If I disable Ansible extension, then only the real word under the cursor, for instance shell will be highlighted (no dash, no colon). And: If I just hover over it, it kind of highlights correctly the part without colon, but as soon as I click to have the real selection, colon is appended.

priyamsahoo commented 1 year ago

I believe it it happening because of the of the . in the module names as each part is considered a separate word. So entire selection means the entire line, which in this case includes the : as well.

Just to verify this, Could you try highlighting and selecting other Ansible keys, like the play and task keywords, or maybe even the module options?

kassi commented 1 year ago

I tested it and it's the same behavior on single words without dots, e.g. tasks, roles, hosts, etc. A single click into the word highlights it incl. colon.

priyamsahoo commented 1 year ago

Yes, you are right. I can replicate the behavior now.

However, we do not change anything in our extension in terms of word separators, I checked in the YAML extension, and the behavior is the same.

For your use case, you need to double-click the key in order to select the key or word (without the :). Single click includes the : as well, just like the YAML extension does.