Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

馃 Pick PR #47830 (fix(47820): Assertion crash when re...) into release-4.6 #47928

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/services/refactors/extractSymbol.ts
Expand Up @@ -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);
Expand All @@ -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)] };
}

Expand Down
9 changes: 9 additions & 0 deletions tests/cases/fourslash/extract-jsdoc.ts
@@ -0,0 +1,9 @@
/// <reference path='fourslash.ts' />

/////**
//// * /*a*//*b*/
//// * {@link Foo}
//// */

goTo.select("a", "b");
verify.not.refactorAvailableForTriggerReason("invoked", "Extract Symbol");