mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-22 09:38:38 +01:00
markdown link smart pasting (#188437)
* making markdown link pasting feature smarter * update validateLink
This commit is contained in:
@@ -7,24 +7,24 @@ 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);
|
||||
export function getDocumentDir(uri: vscode.Uri): vscode.Uri | undefined {
|
||||
const docUri = getParentDocumentUri(uri);
|
||||
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) {
|
||||
export function getParentDocumentUri(uri: vscode.Uri): vscode.Uri {
|
||||
if (uri.scheme === Schemes.notebookCell) {
|
||||
for (const notebook of vscode.workspace.notebookDocuments) {
|
||||
for (const cell of notebook.getCells()) {
|
||||
if (cell.document === document) {
|
||||
if (cell.document.uri.toString() === uri.toString()) {
|
||||
return notebook.uri;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return document.uri;
|
||||
return uri;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user