mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
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:
30
extensions/markdown-language-features/src/util/document.ts
Normal file
30
extensions/markdown-language-features/src/util/document.ts
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user