Fix unpredictable markdown link text when copying permalink from gutter
Right-clicking the gutter to copy a permalink as markdown produced unpredictable link text because getMarkdownLinkText() used the editor selection, which doesn't change on gutter clicks.
Changes
- Extended
PermalinkInfoto include the range used for permalink generation - Modified
getMarkdownLinkText()to accept and prioritize the permalink's range over current selection - Updated
createSinglePermalink()andcreateSingleGitHubLink()to propagate range information
Behavior
Before: Link text could be from previous selection, blank, or arbitrary depending on cursor position
After: Link text extracted from the line the permalink references
Original prompt
This section details on the original issue you should resolve
<issue_title>copy permalink as markdown from gutter has unpredictable behavior</issue_title> <issue_description>Testing microsoft/vscode#177486
right click in the gutter of a ts file in a repository and select 'copy permalink as markdown text'
I've seen: a markdown link using the text from that line or the first line of selected text as link text (expected) a markdown link using previously selected text as link text a markdown link with blank link text a plain link, not markdown
I can't figure out the pattern for which one is chosen</issue_description>
<agent_instructions>Do what the last comment says.</agent_instructions>
Comments on the Issue (you are @copilot in this section)
@rzhao271 I'm not sure if this is the same issue, but I noticed that right-clicking a line number causes that line to be selected, whereas right-clicking the gutter beside a line number doesn't change the selection. This behaviour occurs on the desktop Insiders. Therefore, in the second case, creating a permalink from the context menu that shows up for that right click might make it seem as though the previous selection is being shared, when it's more that the selection hasn't changed.@amunger Seems to repro pretty consistently when opening an editor without giving any focus @amunger maybe, now I can't get it to repro at all, though I'm still not sure where it's grabbing the text from when I don't have anything selected.@amunger when right clicking the gutter, the cursor can be in an unpredictable place. Like in that gif, it looks like files was pulled from the end of the link on the line above the cursor.
- Fixes microsoft/vscode-pull-request-github#4664
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.