Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
534e8f46
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
534e8f46
编写于
1月 09, 2018
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixes #41145
上级
90ef303f
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
39 addition
and
15 deletion
+39
-15
src/vs/base/common/comparers.ts
src/vs/base/common/comparers.ts
+36
-14
src/vs/workbench/api/node/extHostSCM.ts
src/vs/workbench/api/node/extHostSCM.ts
+3
-1
未找到文件。
src/vs/base/common/comparers.ts
浏览文件 @
534e8f46
...
...
@@ -15,7 +15,7 @@ export function setFileNameComparer(collator: Intl.Collator): void {
intlFileNameCollatorIsNumeric
=
collator
.
resolvedOptions
().
numeric
;
}
export
function
compareFileNames
(
one
:
string
,
other
:
string
):
number
{
export
function
compareFileNames
(
one
:
string
,
other
:
string
,
caseSensitive
=
false
):
number
{
if
(
intlFileNameCollator
)
{
const
a
=
one
||
''
;
const
b
=
other
||
''
;
...
...
@@ -30,14 +30,19 @@ export function compareFileNames(one: string, other: string): number {
return
result
;
}
return
noIntlCompareFileNames
(
one
,
other
);
return
noIntlCompareFileNames
(
one
,
other
,
caseSensitive
);
}
const
FileNameMatch
=
/^
(
.*
?)(\.([^
.
]
*
))?
$/
;
export
function
noIntlCompareFileNames
(
one
:
string
,
other
:
string
):
number
{
const
[
oneName
,
oneExtension
]
=
extractNameAndExtension
(
one
,
true
);
const
[
otherName
,
otherExtension
]
=
extractNameAndExtension
(
other
,
true
);
export
function
noIntlCompareFileNames
(
one
:
string
,
other
:
string
,
caseSensitive
=
false
):
number
{
if
(
!
caseSensitive
)
{
one
=
one
&&
one
.
toLowerCase
();
other
=
other
&&
other
.
toLowerCase
();
}
const
[
oneName
,
oneExtension
]
=
extractNameAndExtension
(
one
);
const
[
otherName
,
otherExtension
]
=
extractNameAndExtension
(
other
);
if
(
oneName
!==
otherName
)
{
return
oneName
<
otherName
?
-
1
:
1
;
...
...
@@ -79,8 +84,8 @@ export function compareFileExtensions(one: string, other: string): number {
}
function
noIntlCompareFileExtensions
(
one
:
string
,
other
:
string
):
number
{
const
[
oneName
,
oneExtension
]
=
extractNameAndExtension
(
one
,
true
);
const
[
otherName
,
otherExtension
]
=
extractNameAndExtension
(
other
,
true
);
const
[
oneName
,
oneExtension
]
=
extractNameAndExtension
(
one
&&
one
.
toLowerCase
()
);
const
[
otherName
,
otherExtension
]
=
extractNameAndExtension
(
other
&&
other
.
toLowerCase
()
);
if
(
oneExtension
!==
otherExtension
)
{
return
oneExtension
<
otherExtension
?
-
1
:
1
;
...
...
@@ -93,32 +98,49 @@ function noIntlCompareFileExtensions(one: string, other: string): number {
return
oneName
<
otherName
?
-
1
:
1
;
}
function
extractNameAndExtension
(
str
?:
string
,
lowercase
?:
boolean
):
[
string
,
string
]
{
const
match
=
str
?
FileNameMatch
.
exec
(
lowercase
?
str
.
toLowerCase
()
:
str
)
:
[]
as
RegExpExecArray
;
function
extractNameAndExtension
(
str
?:
string
):
[
string
,
string
]
{
const
match
=
str
?
FileNameMatch
.
exec
(
str
)
:
[]
as
RegExpExecArray
;
return
[(
match
&&
match
[
1
])
||
''
,
(
match
&&
match
[
3
])
||
''
];
}
export
function
comparePaths
(
one
:
string
,
other
:
string
):
number
{
function
comparePathComponents
(
one
:
string
,
other
:
string
,
caseSensitive
=
false
):
number
{
if
(
!
caseSensitive
)
{
one
=
one
&&
one
.
toLowerCase
();
other
=
other
&&
other
.
toLowerCase
();
}
if
(
one
===
other
)
{
return
0
;
}
return
one
<
other
?
-
1
:
1
;
}
export
function
comparePaths
(
one
:
string
,
other
:
string
,
caseSensitive
=
false
):
number
{
const
oneParts
=
one
.
split
(
paths
.
nativeSep
);
const
otherParts
=
other
.
split
(
paths
.
nativeSep
);
const
lastOne
=
oneParts
.
length
-
1
;
const
lastOther
=
otherParts
.
length
-
1
;
let
endOne
:
boolean
,
endOther
:
boolean
,
onePart
:
string
,
otherPart
:
string
;
let
endOne
:
boolean
,
endOther
:
boolean
;
for
(
let
i
=
0
;
;
i
++
)
{
endOne
=
lastOne
===
i
;
endOther
=
lastOther
===
i
;
if
(
endOne
&&
endOther
)
{
return
compareFileNames
(
oneParts
[
i
],
otherParts
[
i
]);
return
compareFileNames
(
oneParts
[
i
],
otherParts
[
i
]
,
caseSensitive
);
}
else
if
(
endOne
)
{
return
-
1
;
}
else
if
(
endOther
)
{
return
1
;
}
else
if
((
onePart
=
oneParts
[
i
].
toLowerCase
())
!==
(
otherPart
=
otherParts
[
i
].
toLowerCase
()))
{
return
onePart
<
otherPart
?
-
1
:
1
;
}
const
result
=
comparePathComponents
(
oneParts
[
i
],
otherParts
[
i
],
caseSensitive
);
if
(
result
!==
0
)
{
return
result
;
}
}
}
...
...
src/vs/workbench/api/node/extHostSCM.ts
浏览文件 @
534e8f46
...
...
@@ -93,7 +93,7 @@ function compareResourceStatesDecorations(a: vscode.SourceControlResourceDecorat
}
function
compareResourceStates
(
a
:
vscode
.
SourceControlResourceState
,
b
:
vscode
.
SourceControlResourceState
):
number
{
let
result
=
comparePaths
(
a
.
resourceUri
.
fsPath
,
b
.
resourceUri
.
fsPath
);
let
result
=
comparePaths
(
a
.
resourceUri
.
fsPath
,
b
.
resourceUri
.
fsPath
,
true
);
if
(
result
!==
0
)
{
return
result
;
...
...
@@ -234,6 +234,8 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
const
snapshot
=
[...
this
.
_resourceStates
].
sort
(
compareResourceStates
);
const
diffs
=
sortedDiff
(
this
.
_resourceSnapshot
,
snapshot
,
compareResourceStates
);
console
.
log
(
diffs
);
const
splices
=
diffs
.
map
<
ISplice
<
{
rawResource
:
SCMRawResource
,
handle
:
number
}
>>
(
diff
=>
{
const
toInsert
=
diff
.
toInsert
.
map
(
r
=>
{
const
handle
=
this
.
_resourceHandlePool
++
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录