* 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)
| 62 | * @returns A list of tokens that we might expand to |
| 63 | */ |
| 64 | function 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 |
no test coverage detected