fix(45687): allow selection to next token (#45695)

This commit is contained in:
Oleksandr T
2021-09-02 21:57:37 +03:00
committed by GitHub
parent 35ada354a3
commit ba3a068614
5 changed files with 58 additions and 1 deletions

View File

@@ -55,7 +55,10 @@ namespace ts.refactor {
const token = getTokenAtPosition(file, span.start);
const importDecl = considerPartialSpans ? findAncestor(token, isImportDeclaration) : getParentNodeInSpan(token, file, span);
if (!importDecl || !isImportDeclaration(importDecl)) return { error: "Selection is not an import declaration." };
if (importDecl.getEnd() < span.start + span.length) return undefined;
const end = span.start + span.length;
const nextToken = findNextToken(importDecl, importDecl.parent, file);
if (nextToken && end > nextToken.getStart()) return undefined;
const { importClause } = importDecl;
if (!importClause) {