Allow external copying files into the workspace on markdown drop / paste (#182572)

Allow copying files in the workspace on markdown drop / paste

Fixes #157043

Also:

- Renames the markdown paste settings and makes them no longer experimental
- Makes the copyFiles setting no longer experimental
- Adds a `markdown.copyFiles.overwriteBehavior` which lets you control if/how existing files are overwritten
This commit is contained in:
Matt Bierner
2023-05-15 20:17:52 -07:00
committed by GitHub
parent 97f8af3e08
commit 7a7d45793b
8 changed files with 435 additions and 252 deletions

View File

@@ -0,0 +1,30 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as vscode from 'vscode';
import { Schemes } from './schemes';
import { Utils } from 'vscode-uri';
export function getDocumentDir(document: vscode.TextDocument): vscode.Uri | undefined {
const docUri = getParentDocumentUri(document);
if (docUri.scheme === Schemes.untitled) {
return vscode.workspace.workspaceFolders?.[0]?.uri;
}
return Utils.dirname(docUri);
}
export function getParentDocumentUri(document: vscode.TextDocument): vscode.Uri {
if (document.uri.scheme === Schemes.notebookCell) {
for (const notebook of vscode.workspace.notebookDocuments) {
for (const cell of notebook.getCells()) {
if (cell.document === document) {
return notebook.uri;
}
}
}
}
return document.uri;
}