diff --git a/src/services/refactors/extractSymbol.ts b/src/services/refactors/extractSymbol.ts index 0120f81cb02a9..9f0392f101478 100644 --- a/src/services/refactors/extractSymbol.ts +++ b/src/services/refactors/extractSymbol.ts @@ -283,7 +283,7 @@ namespace ts.refactor.extractSymbol { // Walk up starting from the the start position until we find a non-SourceFile node that subsumes the selected span. // This may fail (e.g. you select two statements in the root of a source file) - const start = cursorRequest ? getExtractableParent(startToken): getParentNodeInSpan(startToken, sourceFile, adjustedSpan); + const start = cursorRequest ? getExtractableParent(startToken) : getParentNodeInSpan(startToken, sourceFile, adjustedSpan); // Do the same for the ending position const end = cursorRequest ? start : getParentNodeInSpan(endToken, sourceFile, adjustedSpan); @@ -299,7 +299,7 @@ namespace ts.refactor.extractSymbol { return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractRange)] }; } - if (isJSDoc(start)) { + if (start.flags & NodeFlags.JSDoc) { return { errors: [createFileDiagnostic(sourceFile, span.start, length, Messages.cannotExtractJSDoc)] }; } diff --git a/tests/cases/fourslash/extract-jsdoc.ts b/tests/cases/fourslash/extract-jsdoc.ts new file mode 100644 index 0000000000000..bc94fc8ae2792 --- /dev/null +++ b/tests/cases/fourslash/extract-jsdoc.ts @@ -0,0 +1,9 @@ +/// + +/////** +//// * /*a*//*b*/ +//// * {@link Foo} +//// */ + +goTo.select("a", "b"); +verify.not.refactorAvailableForTriggerReason("invoked", "Extract Symbol");