-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Add JSXText check into isValidLocationToAddComment #27653
Conversation
src/services/utilities.ts
Outdated
export function isInJSXText(sourceFile: SourceFile, position: number) { | ||
const token = getTokenAtPosition(sourceFile, position); | ||
if (isJsxText(token)) { | ||
return position >= token.getStart(sourceFile); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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.
return ( | ||
<div> | ||
< | ||
// @ts-ignore |
There was a problem hiding this comment.
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 ?
There was a problem hiding this comment.
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.
Fixes #27552