Skip to content

Markdown: read the markdown.editor.filePaste settings - #350850

Merged
Federico Brancasi (federicobrancasi) merged 1 commit into
mainfrom
fbrancasi/markdown-file-paste-settings
Nov 28, 2026
Merged

Federico Brancasi (federicobrancasi) merged 1 commit into
mainfrom
fbrancasi/markdown-file-paste-settings

Conversation

@federicobrancasi

Copy link
Copy Markdown
Member

The Markdown extension declares markdown.editor.filePaste.enabled and markdown.editor.filePaste.copyIntoWorkspace for pasting files and images, but the paste code reads markdown.editor.paste.enabled and markdown.editor.paste.copyIntoWorkspace. Those names aren't registered, so both settings have had no effect since e5f5e91: with markdown.editor.filePaste.enabled set to never, pasting an image still inserts a Markdown link, and with copyIntoWorkspace set to never, the image is still copied into the workspace. In #210400 a user reported that the setting had no effect. The drop settings and markdown.editor.filePaste.videoSnippet and audioSnippet were already read by their declared names.

This PR reads the declared names in the text editor's paste provider (dropOrPasteResource.ts) and in the Markdown editor's media paste (markdownEditorImagePaste.ts), and fixes the setting names in that file's two error messages.

How to test

The new test sets each setting to never and checks that neither the text editor's paste provider nor the Markdown editor's media paste creates a link or a file. It fails without the fix: both paste the image.

Manually: set "markdown.editor.filePaste.enabled": "never", copy an image and paste it in a Markdown file. No Markdown link is inserted.

Command Result
./scripts/test-integration.sh --suite markdown --grep "Markdown editor image paste" 13 passing; the new test fails without the fix
node_modules/.bin/oxlint on the changed files passed

I compiled the extension with tsc -p extensions/markdown-language-features/tsconfig.json; it reports no errors in the changed files.

The extension declares markdown.editor.filePaste.enabled and
markdown.editor.filePaste.copyIntoWorkspace, but pasting read
markdown.editor.paste.enabled and markdown.editor.paste.copyIntoWorkspace,
which aren't registered, so both settings had no effect. Read the
declared names, also in the Markdown editor's media paste and its error
messages.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI balanced review requested due to automatic review settings November 28, 2026 14:54

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

No active review issues were identified for the Markdown file and media paste setting changes.

No open issues 🎉

What changed in this PR

Fixes Markdown file and media pasting to honor the registered markdown.editor.filePaste.* settings in both the text editor and Markdown editor.

Changes:

  • Corrects configuration reads for paste enablement and copying media into the workspace.
  • Updates two error messages to reference the registered setting names.
  • Adds regression coverage for both settings set to never across both editors.

No actionable issues identified.

File Description
extensions/​markdown-language-features/​src/​test/​markdownEditorImagePaste.test.ts Tests that both paste paths honor the settings.
extensions/​markdown-language-features/​src/​preview/​markdownEditorImagePaste.ts Corrects media-paste setting reads and error messages.
extensions/​markdown-language-features/​src/​languageFeatures/​copyFiles/​dropOrPasteResource.ts Corrects setting reads in the text editor’s paste provider.

Review effort: Balanced

@bhavyaus Bhavya U (bhavyaus) left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved — small, focused change; CI is green.

Merged via the queue into main with commit ec0ee14 Nov 28, 2026
54 checks passed
@federicobrancasi
Federico Brancasi (federicobrancasi) deleted the fbrancasi/markdown-file-paste-settings branch November 28, 2026 17:25
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.

4 participants