Skip to content

Add JSXText check into isValidLocationToAddComment #27653

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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

weswigham
Copy link
Member

Fixes #27552

export function isInJSXText(sourceFile: SourceFile, position: number) {
const token = getTokenAtPosition(sourceFile, position);
if (isJsxText(token)) {
return position >= token.getStart(sourceFile);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably want to use token.pos because getStart will handle parts of the JsxText as trivia.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

on second thought: is this even necessary? JsxText cannot have leading trivia, therefore you can always return true; here

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fair enough; I recognized as much in the other branches.

@weswigham weswigham merged commit 76addd7 into microsoft:master Oct 22, 2018
@weswigham weswigham deleted the fix-jsx-suppression-comment-quickfix branch October 22, 2018 23:45
return (
<div>
<
// @ts-ignore

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vscode completely loses all sense of intellisense when this happens. Seems fine though on the rendering side. Is this a case where we should file an issue against the VSCode repo?

@weswigham any input <3 ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it still happens reliably and you can provide some complete repro steps, a new issue would be pertinent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants