Extract code snippet into stand alone component#1181
Merged
Conversation
aeisenberg
approved these changes
Mar 3, 2022
Contributor
aeisenberg
left a comment
There was a problem hiding this comment.
Approving, assuming you will fix the typo. :)
My comment about the correctness of the locations can be done in the future.
| const isFirstHighlightedLine = lineNumber === highlightedRegion.startLine; | ||
| const isLastHighlightedLine = lineNumber === highlightedRegion.endLine; | ||
|
|
||
| const highlightStartColumn = isSingleLineHighlight |
Contributor
There was a problem hiding this comment.
Going back to our conversation on the previous PR about handling invalid source locs, there are a number of common errors that I think you can handle right here:
if (highlightStartColumn > highilightEndColumn) {
([highlightStartColumn, highilightEndColumn] = [highilightEndColumn, highlightStartColumn]);
}
highlightStartColumn = Math.max(highlightStartColumn, 0);
highilightEndColumn = Math.max(highlightStartColumn, highilightEndColumn);Or some variant of this. It looks like this code won't cause an error if the locations are invalid, but they might cause missing highlights. Again, this is pretty rare, but it does happen.
Contributor
Author
There was a problem hiding this comment.
Thanks for the example/code. Lets discuss validation next week!
| ? highlightedRegion.startColumn | ||
| : 0; | ||
|
|
||
| const highilightEndColumn = isSingleLineHighlight |
Contributor
There was a problem hiding this comment.
Typo: highilightEndColumn -> highlightEndColumn
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Extracts components and logic that help us render code snippets out of
AnalysisAlertResultand into a new stand-alone component so that it can be re-used when showing code paths for problem path queries.The code is mostly a copy of what has been checked in but with a few adjustments:
Note that
AnalysisAlertResultis really quite thin now and could be incorporated back intoRemoteQueries.tsxbut I think it'll get a bit more meat to it once we do code paths.Checklist
N/A:
ready-for-doc-reviewlabel there.