vscode-ghc-mod icon indicating copy to clipboard operation
vscode-ghc-mod copied to clipboard

Go to Definition does not work when text is selected

Open danstiner opened this issue 8 years ago • 2 comments

This is because the position given in the onDefinition handler seems to be after the selected text. Other language extensions rely on document.getWordRangeAtPosition to handle this.

This will take some more thought and probably looking at how getWordRangeAtPosition works, I would guess it is not sufficient as is for our uses (probably does not handle operators next to symbols with no space in between).

danstiner avatar Mar 29 '17 16:03 danstiner

Is getWordRangeAtPosition only available in newer vscode api versions? I don't see it in the current definitions.

At any rate, the signature takes a regex so it looks pretty easy to integrate into the existing logic, it even simplifies things a bit for us not needing to do our own broken expansion to a word from a position!

		 /**
		 * 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. It
		 * is also possible to provide a custom regular expression.
		 *
		 * The position will be [adjusted](#TextDocument.validatePosition).
		 *
		 * @param position A position.
		 * @param regex Optional regular expression that describes what a word is.
		 * @return A range spanning a word, or `undefined`.
		 */
		getWordRangeAtPosition(position: Position, regex?: RegExp): Range | undefined;

danstiner avatar Mar 29 '17 16:03 danstiner

I confirm this is happening to me too

nebtrx avatar Mar 30 '17 18:03 nebtrx