Use desired file name when generating new md pasted file paths (#183861)

Fixes #183851
This commit is contained in:
Matt Bierner 2023-05-30 12:54:18 -07:00 committed by GitHub
parent 5f37021eeb
commit 50527c97d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -2,7 +2,6 @@
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as path from 'path';
import * as picomatch from 'picomatch';
import * as vscode from 'vscode';
import { Utils } from 'vscode-uri';
@ -43,8 +42,9 @@ export class NewFilePathGenerator {
const desiredPath = getDesiredNewFilePath(config, document, file);
const root = Utils.dirname(desiredPath);
const ext = path.extname(file.name);
const baseName = path.basename(file.name, ext);
const ext = Utils.extname(desiredPath);
let baseName = Utils.basename(desiredPath);
baseName = baseName.slice(0, baseName.length - ext.length);
for (let i = 0; ; ++i) {
if (token.isCancellationRequested) {
return undefined;