Skip to content

Commit

Permalink
Opening file with same name but different folder appends a suffix to …
Browse files Browse the repository at this point in the history
…the filename (fix #143414)
  • Loading branch information
bpasero committed Mar 2, 2022
1 parent eca9017 commit 6f906f3
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/vs/platform/files/browser/htmlFileSystemProvider.ts
Expand Up @@ -10,7 +10,7 @@ import { CancellationToken } from 'vs/base/common/cancellation';
import { Event } from 'vs/base/common/event';
import { Disposable, IDisposable } from 'vs/base/common/lifecycle';
import { Schemas } from 'vs/base/common/network';
import { normalize } from 'vs/base/common/path';
import { basename, extname, normalize } from 'vs/base/common/path';
import { isLinux } from 'vs/base/common/platform';
import { extUri, extUriIgnorePathCase } from 'vs/base/common/resources';
import { newWriteableStream, ReadableStreamEvents } from 'vs/base/common/stream';
Expand Down Expand Up @@ -314,9 +314,12 @@ export class HTMLFileSystemProvider implements IFileSystemProviderWithFileReadWr

// Compute a valid handle ID in case this exists already
if (map.has(handleId) && !await map.get(handleId)?.isSameEntry(handle)) {
let handleIdCounter = 2;
const fileExt = extname(handle.name);
const fileName = basename(handle.name, fileExt);

let handleIdCounter = 1;
do {
handleId = `/${handle.name}-${handleIdCounter++}`;
handleId = `/${fileName}-${handleIdCounter++}${fileExt}`;
} while (map.has(handleId) && !await map.get(handleId)?.isSameEntry(handle));
}

Expand Down

0 comments on commit 6f906f3

Please sign in to comment.