From 4ee40e74e1e29178f05f82d026b555490c726772 Mon Sep 17 00:00:00 2001 From: Benjamin Pasero Date: Sat, 10 Jul 2021 08:23:47 +0200 Subject: [PATCH] Default presentation of Explorer: Copy Relative Path Separator in Setting editor is confusing (fix #128345) --- src/vs/workbench/contrib/files/browser/fileCommands.ts | 9 ++++++++- .../contrib/files/browser/files.contribution.ts | 7 +++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/files/browser/fileCommands.ts b/src/vs/workbench/contrib/files/browser/fileCommands.ts index d834b54f85aaa..7a57e7ccb92e4 100644 --- a/src/vs/workbench/contrib/files/browser/fileCommands.ts +++ b/src/vs/workbench/contrib/files/browser/fileCommands.ts @@ -275,7 +275,14 @@ CommandsRegistry.registerCommand({ async function resourcesToClipboard(resources: URI[], relative: boolean, clipboardService: IClipboardService, labelService: ILabelService, configurationService: IConfigurationService): Promise { if (resources.length) { const lineDelimiter = isWindows ? '\r\n' : '\n'; - const separator = relative ? configurationService.getValue<'/' | '\\' | undefined>('explorer.copyRelativePathSeparator') : undefined; + + let separator: '/' | '\\' | undefined = undefined; + if (relative) { + const relativeSeparator = configurationService.getValue('explorer.copyRelativePathSeparator'); + if (relativeSeparator === '/' || relativeSeparator === '\\') { + separator = relativeSeparator; + } + } const text = resources.map(resource => labelService.getUriLabel(resource, { relative, noPrefix: true, separator })).join(lineDelimiter); await clipboardService.writeText(text); diff --git a/src/vs/workbench/contrib/files/browser/files.contribution.ts b/src/vs/workbench/contrib/files/browser/files.contribution.ts index 6b5c655053128..6e87acfd99b1b 100644 --- a/src/vs/workbench/contrib/files/browser/files.contribution.ts +++ b/src/vs/workbench/contrib/files/browser/files.contribution.ts @@ -407,13 +407,16 @@ configurationRegistry.registerConfiguration({ 'type': 'string', 'enum': [ '/', - '\\' + '\\', + 'auto' ], 'enumDescriptions': [ nls.localize('copyRelativePathSeparator.slash', "Use slash as path separation character."), nls.localize('copyRelativePathSeparator.backslash', "Use backslash as path separation character."), + nls.localize('copyRelativePathSeparator.auto', "Uses operating system specific path separation character."), ], - 'description': nls.localize('copyRelativePathSeparator', "The path separation character used when copying relative file paths. Will use the operating system default unless specified."), + 'description': nls.localize('copyRelativePathSeparator', "The path separation character used when copying relative file paths."), + 'default': 'auto' } } });