Skip to content

Conversation

Copy link
Contributor

Copilot AI commented Jan 26, 2026

"Copy GitHub Permalink as Markdown" from file tab context menu incorrectly uses the text at cursor position instead of the filename for the link text.

Changes

  • Modified copyMarkdownPermalink in src/issues/issueFeatureRegistrar.ts to detect invocation source
  • When context is a vscode.Uri (tab context menu): use filename
  • When context is an EditorLineNumberContext (gutter click): preserve existing behavior using selection text
const firstContext = context.length > 0 ? context[0] : undefined;
const contextIsFromTab = firstContext instanceof vscode.Uri;

if (withPermalinks.length === 1 && !contextIsFromTab) {
    const selection = this.getMarkdownLinkText(withPermalinks[0].range);
    // ... use selection text
}
// Otherwise use filename
Original prompt

This section details on the original issue you should resolve

<issue_title>Share permalink as markdown on tab should use filename for link text</issue_title>
<issue_description>Testing microsoft/vscode#177486

open a file and place your cursor somewhere in that file
right click the file tab and 'share github permalink as markdown`
🐛 the generated link will use the text at the cursor location, but seems like it should just be the filename
if the cursor isn't in that file, then the text seems to be picked up from its last location, possibly from another window</issue_description>

<agent_instructions>Pay special attention to #4663 (comment)</agent_instructions>

Comments on the Issue (you are @copilot in this section)

@amunger the command will use the line as text when the editor is focused, and the filename if the editor is not focused.

💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

Copilot AI and others added 2 commits January 26, 2026 15:38
Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
…context menu

Co-authored-by: alexr00 <38270282+alexr00@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix permalink markdown link text to use filename Fix share permalink as markdown to use filename when invoked from tab context menu Jan 26, 2026
Copilot AI requested a review from alexr00 January 26, 2026 15:44
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.

Share permalink as markdown on tab should use filename for link text

2 participants