GitHub permalinks: Deduplicate the line number if the range is one line.#2980
Merged
alexr00 merged 2 commits intomicrosoft:mainfrom Sep 23, 2021
lgarron:deduplicate-single-line-range
Merged
GitHub permalinks: Deduplicate the line number if the range is one line.#2980alexr00 merged 2 commits intomicrosoft:mainfrom lgarron:deduplicate-single-line-range
alexr00 merged 2 commits intomicrosoft:mainfrom
lgarron:deduplicate-single-line-range
Conversation
lgarron
commented
Sep 1, 2021
src/issues/util.ts
Outdated
Contributor
Author
There was a problem hiding this comment.
This could theoretically be kept one one line, or shortened by conditionally updating a variable in the main block for createGithubPermalink(). However, I thought this would be the easiest to read, since it contains the calculation entirely inside a separate block without side effects.
Contributor
Author
There was a problem hiding this comment.
One line would look something like this:
const rangeString = range ? `#L${range.start.line + 1}${range.start.line === range.end.line ? '' : `-L${range.end.line + 1}`}` : '';
Contributor
Author
There was a problem hiding this comment.
Putting it in the same in the main block for createGithubPermalink() could look like this:
let rangeString = '';
if (range) {
rangeString = `#L${range.start.line + 1}`;
if (range.start.line !== range.end.line) {
rangeString += `-L${range.end.line + 1}`;
}
}This will generate URLs like: https://github.com/microsoft/vscode-pull-request-github/blob/39d333d9931d685d01078e27c4e6583eda55fc27/src/issues/util.ts#L495 ... instead of: https://github.com/microsoft/vscode-pull-request-github/blob/39d333d9931d685d01078e27c4e6583eda55fc27/src/issues/util.ts#L495-L495
alexr00
requested changes
Sep 22, 2021
Member
alexr00
left a comment
There was a problem hiding this comment.
Thanks for the PR! Just one comment.
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.
This will generate URLs like:
https://github.com/microsoft/vscode-pull-request-github/blob/39d333d9931d685d01078e27c4e6583eda55fc27/src/issues/util.ts#L495... instead of:
https://github.com/microsoft/vscode-pull-request-github/blob/39d333d9931d685d01078e27c4e6583eda55fc27/src/issues/util.ts#L495-L495