Skip to content

Commit

Permalink
Disable md paste file path in untitled notebooks
Browse files Browse the repository at this point in the history
Fixes microsoft#194809

Since the notebook does not exist on disk yet, there's no way to write a relative path in it. Just disable the feature since there's nothing else we can reasonably do here
  • Loading branch information
mjbvz committed Nov 15, 2023
1 parent 5fcda6b commit f946903
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as vscode from 'vscode';
import { Mime, mediaMimes } from '../../util/mimes';
import { Schemes } from '../../util/schemes';
import { createEditForMediaFiles, tryGetUriListSnippet } from './shared';
import { getParentDocumentUri } from '../../util/document';

class ResourceDropProvider implements vscode.DocumentDropEditProvider {

Expand Down Expand Up @@ -58,7 +59,7 @@ class ResourceDropProvider implements vscode.DocumentDropEditProvider {
}

private async _getMediaFilesEdit(document: vscode.TextDocument, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.DocumentDropEdit | undefined> {
if (document.uri.scheme === Schemes.untitled) {
if (getParentDocumentUri(document.uri).scheme === Schemes.untitled) {
return;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import * as vscode from 'vscode';
import { Mime, mediaMimes } from '../../util/mimes';
import { Schemes } from '../../util/schemes';
import { PasteUrlAsFormattedLink, createEditAddingLinksForUriList, createEditForMediaFiles, getPasteUrlAsFormattedLinkSetting } from './shared';
import { getParentDocumentUri } from '../../util/document';

class PasteResourceEditProvider implements vscode.DocumentPasteEditProvider {

Expand Down Expand Up @@ -64,7 +65,7 @@ class PasteResourceEditProvider implements vscode.DocumentPasteEditProvider {
}

private async _getMediaFilesEdit(document: vscode.TextDocument, dataTransfer: vscode.DataTransfer, token: vscode.CancellationToken): Promise<vscode.DocumentPasteEdit | undefined> {
if (document.uri.scheme === Schemes.untitled) {
if (getParentDocumentUri(document.uri).scheme === Schemes.untitled) {
return;
}

Expand Down

0 comments on commit f946903

Please sign in to comment.