mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 21:09:43 +00:00
uriDisplay: drive letter polish
This commit is contained in:
parent
501156e3c2
commit
f466647f91
|
@ -11,7 +11,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
|
|||
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
|
||||
import { isEqual, basenameOrAuthority } from 'vs/base/common/resources';
|
||||
import { isLinux, isWindows } from 'vs/base/common/platform';
|
||||
import { tildify, normalizeDriveLetter } from 'vs/base/common/labels';
|
||||
import { tildify } from 'vs/base/common/labels';
|
||||
import { ltrim } from 'vs/base/common/strings';
|
||||
|
||||
export interface IUriDisplayService {
|
||||
|
@ -32,7 +32,7 @@ const sepRegexp = /\//g;
|
|||
const labelMatchingRegexp = /\$\{scheme\}|\$\{authority\}|\$\{path\}/g;
|
||||
|
||||
function hasDriveLetter(path: string): boolean {
|
||||
return isWindows && path && path[1] === ':';
|
||||
return isWindows && path && path[2] === ':';
|
||||
}
|
||||
|
||||
export class UriDisplayService implements IUriDisplayService {
|
||||
|
@ -96,9 +96,9 @@ export class UriDisplayService implements IUriDisplayService {
|
|||
}
|
||||
});
|
||||
|
||||
// convert c:\something => C:\something
|
||||
// convert \c:\something => C:\something
|
||||
if (formater.normalizeDriveLetter && hasDriveLetter(label)) {
|
||||
label = normalizeDriveLetter(label);
|
||||
label = label.charAt(1).toUpperCase() + label.substr(2);
|
||||
}
|
||||
|
||||
if (formater.tildify) {
|
||||
|
|
|
@ -30,7 +30,7 @@ suite('URI Display', () => {
|
|||
|
||||
const uri1 = TestWorkspace.folders[0].uri.with({ path: TestWorkspace.folders[0].uri.path.concat('/a/b/c/d') });
|
||||
assert.equal(uriDisplayService.getLabel(uri1, true), isWindows ? 'a\\b\\c\\d' : 'a/b/c/d');
|
||||
assert.equal(uriDisplayService.getLabel(uri1, false), isWindows ? '\\testWorkspace\\a\\b\\c\\d' : '/testWorkspace/a/b/c/d');
|
||||
assert.equal(uriDisplayService.getLabel(uri1, false), isWindows ? 'C:\\testWorkspace\\a\\b\\c\\d' : '/testWorkspace/a/b/c/d');
|
||||
|
||||
const uri2 = URI.file('c:\\1/2/3');
|
||||
assert.equal(uriDisplayService.getLabel(uri2, false), isWindows ? 'C:\\1\\2\\3' : '/c:\\1/2/3');
|
||||
|
|
Loading…
Reference in a new issue