Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Dec 9, 2025

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 PermalinkInfo to include the range used for permalink generation
  • Modified getMarkdownLinkText() to accept and prioritize the permalink's range over current selection
  • Updated createSinglePermalink() and createSingleGitHubLink() 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 ![markdownLink](https://user-images.githubusercontent.com/2019016/227027228-3040f93e-682c-436f-ae96-c350fbc3d0c0.gif) @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.

✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copilot AI and others added 3 commits December 9, 2025 16:36
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
- Add range field to PermalinkInfo to track the range used for the permalink
- Update getMarkdownLinkText to accept and use the permalink range
- When copying markdown permalink, extract text from the correct line/range
- Fixes issue where right-clicking gutter would use previous selection text

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix unpredictable behavior when copying permalink as markdown Fix unpredictable markdown link text when copying permalink from gutter Dec 9, 2025
Copilot AI requested a review from alexr00 December 9, 2025 16:52
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.

copy permalink as markdown from gutter has unpredictable behavior

2 participants