Make markdown link pasting feature smarter (#187170)

* making markdown link pasting feature smarter

* Update settings description

Co-authored-by: Joyce Er <joyceerhl@gmail.com>

* made checkPaste more concise

* won't paste md link in fenced code or math

---------

Co-authored-by: Joyce Er <joyceerhl@gmail.com>
This commit is contained in:
Meghan Kulkarni
2023-07-10 14:11:49 -07:00
committed by GitHub
parent 261a75e3a4
commit f07abd224b
5 changed files with 62 additions and 17 deletions

View File

@@ -5,7 +5,6 @@
import * as vscode from 'vscode';
import { getMarkdownLink } from './shared';
class PasteLinkEditProvider implements vscode.DocumentPasteEditProvider {
readonly id = 'insertMarkdownLink';
@@ -15,8 +14,8 @@ class PasteLinkEditProvider implements vscode.DocumentPasteEditProvider {
dataTransfer: vscode.DataTransfer,
token: vscode.CancellationToken,
): Promise<vscode.DocumentPasteEdit | undefined> {
const enabled = vscode.workspace.getConfiguration('markdown', document).get('editor.pasteUrlAsFormattedLink.enabled', true);
if (!enabled) {
const enabled = vscode.workspace.getConfiguration('markdown', document).get<'always' | 'smart' | 'never'>('editor.pasteUrlAsFormattedLink.enabled', 'smart');
if (enabled === 'never') {
return;
}