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

getWordRangeAtPosition does not respect word separator settings #8233

Closed
indiejames opened this issue Jun 28, 2016 · 5 comments
Closed

getWordRangeAtPosition does not respect word separator settings #8233

indiejames opened this issue Jun 28, 2016 · 5 comments
Assignees

Comments

@indiejames
Copy link

  • VSCode Version: 1.2.1
  • OS Version: OX X El Capitan 10.11.5

Steps to Reproduce:

  1. Edit user preferences to set "editor.wordSeparators": " ()"':,;~@#$%^&{}[]`"
  2. Call getWordRangeAtPosition with a position inside a string like "clojure.test".
    Result: Returned range only contains "clojure" or "test" depending on chosen position.
    Expected result: Returned range contains entire string "clojure.test".
@alexdima
Copy link
Member

The TextDocument.getWordRangeAtPosition respects the word definition provided by the language associated with the TextDocument. It is configured by languages according to language specific rules via languages.setLanguageConfiguration.

For example, css defines that - is not a separator. For example, when dealing with a TextDocument that has language set to css, - will not be a separator.

I agree there is ambiguity here, as this uses the word definition of a language and not the word definition of the end user. Any thoughts on how to improve here to reduce confusion?

        /**
         * Get a word-range at the given position. By default words are defined by
         * common separators, like space, -, _, etc. In addition, per languge custom
         * [word definitions](#LanguageConfiguration.wordPattern) can be defined.
         *
         * The position will be [adjusted](#TextDocument.validatePosition).
         *
         * @param position A position.
         * @return A range spanning a word, or `undefined`.
         */
        getWordRangeAtPosition(position: Position): Range;

@indiejames
Copy link
Author

I saw this docstring in the hover info for getWordRangeAtPosition, but unfortunately the link [word definitions] does not perform any action when I click on it (like opening in a browser or view). So I did not realize there was an explanation for how to do this. Given that I think what you have is sufficient. I will try to add a language customization and see if it works as it should. If so I will close this issue.

Thanks,
James

@indiejames
Copy link
Author

Verified that getWordRangeAtPosition respects language settings.

@alexdima
Copy link
Member

@jrieken -- [word definitions](#LanguageConfiguration.wordPattern) can be defined. - do you have any idea how we can make sure these links are not broken

@jrieken
Copy link
Member

jrieken commented Jun 29, 2016

We only use (and can verify) them when the html doc page has been generated. For each symbol (class, interface, enum, method, etc) we generate a anchor-target with its name. Only then those links work...

@vscodebot vscodebot bot locked and limited conversation to collaborators Nov 18, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants