MCPcopy Create free account
hub / github.com/cursorless-dev/cursorless / getRelevantTokens

Function getRelevantTokens

src/processTargets/processMark.ts:64–83  ·  view source on GitHub ↗

* Given a selection, finds all tokens that we might use to expand the * selection. Just looks at tokens on the same line as the start and end of the * selection, because we assume that a token cannot span multiple lines. * @param selection The selection we care about * @returns A list of tokens

(selection: SelectionWithEditor)

Source from the content-addressed store, hash-verified

62 * @returns A list of tokens that we might expand to
63 */
64function getRelevantTokens(selection: SelectionWithEditor) {
65 const startLine = selection.selection.start.line;
66 const endLine = selection.selection.end.line;
67
68 let tokens = getTokensInRange(
69 selection.editor,
70 selection.editor.document.lineAt(startLine).range
71 );
72
73 if (endLine !== startLine) {
74 tokens.push(
75 ...getTokensInRange(
76 selection.editor,
77 selection.editor.document.lineAt(endLine).range
78 )
79 );
80 }
81
82 return tokens;
83}
84
85/**
86 * Given a selection returns a new selection which contains the tokens

Callers 1

Calls 1

getTokensInRangeFunction · 0.90

Tested by

no test coverage detected