264
265
public getWordAtPosition(_position: IPosition): IWordAtPosition | null {
267
>
268
>
const position = this._textModel.validatePosition(_position);
269
>
const lineContent = this._textModel.getLineContent(position.lineNumber);
270
>
const lineTokens = this.getLineTokens(position.lineNumber);
271
>
const tokenIndex = lineTokens.findTokenIndexAtOffset(position.column - 1);
272
>
273
>
// (1). First try checking right biased word
274
>
const [rbStartOffset, rbEndOffset] = TokenizationTextModelPart._findLanguageBoundaries(lineTokens, tokenIndex);
275
>
const rightBiasedWord = getWordAtText(
276
>
position.column,
277
>
this.getLanguageConfiguration(lineTokens.getLanguageId(tokenIndex)).getWordDefinition(),
278
>
lineContent.substring(rbStartOffset, rbEndOffset),
279
>
rbStartOffset
280
>
);
281
>
// Make sure the result touches the original passed in position
282
>
if (
283
>
rightBiasedWord &&
284
rightBiasedWord.startColumn <= _position.column &&
285
_position.column <= rightBiasedWord.endColumn
287
return rightBiasedWord;
288
}
289
290
// (2). Else, if we were at a language boundary, check the left biased word
292
// edge case, where `position` sits between two tokens belonging to two different languages
293
const [lbStartOffset, lbEndOffset] = TokenizationTextModelPart._findLanguageBoundaries(