Skip to content

Commit 9c95828

Browse files
authored
Enable paste url for file uris (microsoft#203270)
Fixes microsoft#203180
1 parent c77b63e commit 9c95828

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

extensions/markdown-language-features/src/languageFeatures/copyFiles/pasteUrlProvider.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ import * as vscode from 'vscode';
77
import { IMdParser } from '../../markdownEngine';
88
import { ITextDocument } from '../../types/textDocument';
99
import { Mime } from '../../util/mimes';
10-
import { createInsertUriListEdit, externalUriSchemes } from './shared';
10+
import { createInsertUriListEdit } from './shared';
11+
import { Schemes } from '../../util/schemes';
1112

1213
export enum PasteUrlAsMarkdownLink {
1314
Always = 'always',
@@ -170,6 +171,14 @@ async function shouldSmartPasteForSelection(
170171
return true;
171172
}
172173

174+
175+
const externalUriSchemes: ReadonlySet<string> = new Set([
176+
Schemes.http,
177+
Schemes.https,
178+
Schemes.mailto,
179+
Schemes.file,
180+
]);
181+
173182
export function findValidUriInText(text: string): string | undefined {
174183
const trimmedUrlList = text.trim();
175184

@@ -186,7 +195,7 @@ export function findValidUriInText(text: string): string | undefined {
186195
return;
187196
}
188197

189-
if (!externalUriSchemes.includes(uri.scheme.toLowerCase()) || uri.authority.length <= 1) {
198+
if (!externalUriSchemes.has(uri.scheme.toLowerCase()) || uri.authority.length <= 1) {
190199
return;
191200
}
192201

extensions/markdown-language-features/src/languageFeatures/copyFiles/shared.ts

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ enum MediaKind {
1919
Audio,
2020
}
2121

22-
export const externalUriSchemes = [
23-
'http',
24-
'https',
25-
'mailto',
26-
];
27-
2822
export const mediaFileExtensions = new Map<string, MediaKind>([
2923
// Images
3024
['bmp', MediaKind.Image],

extensions/markdown-language-features/src/util/schemes.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
*--------------------------------------------------------------------------------------------*/
55

66
export const Schemes = Object.freeze({
7+
http: 'http',
8+
https: 'https',
79
file: 'file',
810
untitled: 'untitled',
911
mailto: 'mailto',

0 commit comments

Comments
 (0)