Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
48b58bdf
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,发现更多精彩内容 >>
提交
48b58bdf
编写于
9月 06, 2017
作者:
J
Joao
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
scm: use diff algorithm for ext host communication
上级
e34900af
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
109 addition
and
58 deletion
+109
-58
src/vs/workbench/api/electron-browser/mainThreadSCM.ts
src/vs/workbench/api/electron-browser/mainThreadSCM.ts
+34
-27
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+9
-3
src/vs/workbench/api/node/extHostSCM.ts
src/vs/workbench/api/node/extHostSCM.ts
+66
-28
未找到文件。
src/vs/workbench/api/electron-browser/mainThreadSCM.ts
浏览文件 @
48b58bdf
...
@@ -13,7 +13,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
...
@@ -13,7 +13,7 @@ import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import
{
ISCMService
,
ISCMRepository
,
ISCMProvider
,
ISCMResource
,
ISCMResourceGroup
,
ISCMResourceDecorations
}
from
'
vs/workbench/services/scm/common/scm
'
;
import
{
ISCMService
,
ISCMRepository
,
ISCMProvider
,
ISCMResource
,
ISCMResourceGroup
,
ISCMResourceDecorations
}
from
'
vs/workbench/services/scm/common/scm
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ExtHostContext
,
MainThreadSCMShape
,
ExtHostSCMShape
,
SCMProviderFeatures
,
SCMRawResource
Group
,
SCMGroupFeatures
,
MainContext
,
IExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
ExtHostContext
,
MainThreadSCMShape
,
ExtHostSCMShape
,
SCMProviderFeatures
,
SCMRawResource
Splices
,
SCMGroupFeatures
,
MainContext
,
IExtHostContext
}
from
'
../node/extHost.protocol
'
;
import
{
Command
}
from
'
vs/editor/common/modes
'
;
import
{
Command
}
from
'
vs/editor/common/modes
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
import
{
extHostNamedCustomer
}
from
'
vs/workbench/api/electron-browser/extHostCustomers
'
;
...
@@ -155,36 +155,43 @@ class MainThreadSCMProvider implements ISCMProvider {
...
@@ -155,36 +155,43 @@ class MainThreadSCMProvider implements ISCMProvider {
this
.
_onDidChange
.
fire
();
this
.
_onDidChange
.
fire
();
}
}
$
updateGroupResourceStates
(
groups
:
SCMRawResourceGroup
[]):
void
{
$
spliceGroupResourceStates
(
slices
:
SCMRawResourceSplices
[]):
void
{
for
(
const
[
groupHandle
,
resources
]
of
group
s
)
{
for
(
const
[
groupHandle
,
groupSlices
]
of
slice
s
)
{
const
group
=
this
.
_groupsByHandle
[
groupHandle
];
const
group
=
this
.
_groupsByHandle
[
groupHandle
];
if
(
!
group
)
{
if
(
!
group
)
{
return
;
return
;
}
}
group
.
resources
=
resources
.
map
(
rawResource
=>
{
// reverse the splices sequence in order to apply them correctly
const
[
handle
,
sourceUri
,
command
,
icons
,
tooltip
,
strikeThrough
,
faded
]
=
rawResource
;
groupSlices
.
reverse
();
const
icon
=
icons
[
0
];
const
iconDark
=
icons
[
1
]
||
icon
;
for
(
const
[
start
,
deleteCount
,
rawResources
]
of
groupSlices
)
{
const
decorations
=
{
const
resources
=
rawResources
.
map
(
rawResource
=>
{
icon
:
icon
&&
URI
.
parse
(
icon
),
const
[
handle
,
sourceUri
,
command
,
icons
,
tooltip
,
strikeThrough
,
faded
]
=
rawResource
;
iconDark
:
iconDark
&&
URI
.
parse
(
iconDark
),
const
icon
=
icons
[
0
];
tooltip
,
const
iconDark
=
icons
[
1
]
||
icon
;
strikeThrough
,
const
decorations
=
{
faded
icon
:
icon
&&
URI
.
parse
(
icon
),
};
iconDark
:
iconDark
&&
URI
.
parse
(
iconDark
),
tooltip
,
return
new
MainThreadSCMResource
(
strikeThrough
,
this
.
handle
,
faded
groupHandle
,
};
handle
,
URI
.
parse
(
sourceUri
),
return
new
MainThreadSCMResource
(
command
,
this
.
handle
,
group
,
groupHandle
,
decorations
handle
,
);
URI
.
parse
(
sourceUri
),
});
command
,
group
,
decorations
);
});
group
.
resources
.
splice
(
start
,
deleteCount
,
...
resources
);
}
}
}
this
.
_onDidChangeResources
.
fire
();
this
.
_onDidChangeResources
.
fire
();
...
@@ -317,7 +324,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
...
@@ -317,7 +324,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
provider
.
$updateGroupLabel
(
groupHandle
,
label
);
provider
.
$updateGroupLabel
(
groupHandle
,
label
);
}
}
$
updateResourceStates
(
sourceControlHandle
:
number
,
resources
:
SCMRawResourceGroup
[]):
void
{
$
spliceResourceStates
(
sourceControlHandle
:
number
,
splices
:
SCMRawResourceSplices
[]):
void
{
const
repository
=
this
.
_repositories
[
sourceControlHandle
];
const
repository
=
this
.
_repositories
[
sourceControlHandle
];
if
(
!
repository
)
{
if
(
!
repository
)
{
...
@@ -325,7 +332,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
...
@@ -325,7 +332,7 @@ export class MainThreadSCM implements MainThreadSCMShape {
}
}
const
provider
=
repository
.
provider
as
MainThreadSCMProvider
;
const
provider
=
repository
.
provider
as
MainThreadSCMProvider
;
provider
.
$
updateGroupResourceStates
(
resour
ces
);
provider
.
$
spliceGroupResourceStates
(
spli
ces
);
}
}
$unregisterGroup
(
sourceControlHandle
:
number
,
handle
:
number
):
void
{
$unregisterGroup
(
sourceControlHandle
:
number
,
handle
:
number
):
void
{
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
48b58bdf
...
@@ -337,11 +337,17 @@ export type SCMRawResource = [
...
@@ -337,11 +337,17 @@ export type SCMRawResource = [
boolean
/*faded*/
boolean
/*faded*/
];
];
export
type
SCMRawResourceGroup
=
[
export
type
SCMRawResourceSplice
=
[
number
,
/*handle*/
number
/* start */
,
number
/* delete count */
,
SCMRawResource
[]
SCMRawResource
[]
];
];
export
type
SCMRawResourceSplices
=
[
number
,
/*handle*/
SCMRawResourceSplice
[]
];
export
interface
MainThreadSCMShape
extends
IDisposable
{
export
interface
MainThreadSCMShape
extends
IDisposable
{
$registerSourceControl
(
handle
:
number
,
id
:
string
,
label
:
string
):
void
;
$registerSourceControl
(
handle
:
number
,
id
:
string
,
label
:
string
):
void
;
$updateSourceControl
(
handle
:
number
,
features
:
SCMProviderFeatures
):
void
;
$updateSourceControl
(
handle
:
number
,
features
:
SCMProviderFeatures
):
void
;
...
@@ -352,7 +358,7 @@ export interface MainThreadSCMShape extends IDisposable {
...
@@ -352,7 +358,7 @@ export interface MainThreadSCMShape extends IDisposable {
$updateGroupLabel
(
sourceControlHandle
:
number
,
handle
:
number
,
label
:
string
):
void
;
$updateGroupLabel
(
sourceControlHandle
:
number
,
handle
:
number
,
label
:
string
):
void
;
$unregisterGroup
(
sourceControlHandle
:
number
,
handle
:
number
):
void
;
$unregisterGroup
(
sourceControlHandle
:
number
,
handle
:
number
):
void
;
$
updateResourceStates
(
sourceControlHandle
:
number
,
resources
:
SCMRawResourceGroup
[]):
void
;
$
spliceResourceStates
(
sourceControlHandle
:
number
,
splices
:
SCMRawResourceSplices
[]):
void
;
$setInputBoxValue
(
sourceControlHandle
:
number
,
value
:
string
):
void
;
$setInputBoxValue
(
sourceControlHandle
:
number
,
value
:
string
):
void
;
}
}
...
...
src/vs/workbench/api/node/extHostSCM.ts
浏览文件 @
48b58bdf
...
@@ -12,8 +12,9 @@ import { dispose, IDisposable } from 'vs/base/common/lifecycle';
...
@@ -12,8 +12,9 @@ import { dispose, IDisposable } from 'vs/base/common/lifecycle';
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
ExtHostCommands
,
CommandsConverter
}
from
'
vs/workbench/api/node/extHostCommands
'
;
import
{
ExtHostCommands
,
CommandsConverter
}
from
'
vs/workbench/api/node/extHostCommands
'
;
import
{
MainContext
,
MainThreadSCMShape
,
SCMRawResource
,
SCMRawResource
Group
,
IMainContext
}
from
'
./extHost.protocol
'
;
import
{
MainContext
,
MainThreadSCMShape
,
SCMRawResource
,
SCMRawResource
Splice
,
SCMRawResourceSplices
,
IMainContext
}
from
'
./extHost.protocol
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
vscode
from
'
vscode
'
;
import
{
LcsDiff
,
ISequence
}
from
'
vs/base/common/diff/diff
'
;
function
getIconPath
(
decorations
:
vscode
.
SourceControlResourceThemableDecorations
)
{
function
getIconPath
(
decorations
:
vscode
.
SourceControlResourceThemableDecorations
)
{
if
(
!
decorations
)
{
if
(
!
decorations
)
{
...
@@ -59,6 +60,22 @@ export class ExtHostSCMInputBox {
...
@@ -59,6 +60,22 @@ export class ExtHostSCMInputBox {
}
}
}
}
class
ResourceSequence
implements
ISequence
{
constructor
(
private
resources
:
vscode
.
SourceControlResourceState
[])
{
}
getLength
()
{
return
this
.
resources
.
length
;
}
getElementHash
(
index
)
{
const
resource
=
this
.
resources
[
index
];
// TODO!!!
return
resource
.
resourceUri
.
toString
();
}
}
class
ExtHostSourceControlResourceGroup
implements
vscode
.
SourceControlResourceGroup
{
class
ExtHostSourceControlResourceGroup
implements
vscode
.
SourceControlResourceGroup
{
private
static
_handlePool
:
number
=
0
;
private
static
_handlePool
:
number
=
0
;
...
@@ -73,6 +90,9 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
...
@@ -73,6 +90,9 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
private
_onDidDispose
=
new
Emitter
<
void
>
();
private
_onDidDispose
=
new
Emitter
<
void
>
();
readonly
onDidDispose
=
this
.
_onDidDispose
.
event
;
readonly
onDidDispose
=
this
.
_onDidDispose
.
event
;
private
_handlesSnapshot
:
number
[]
=
[];
private
_resourcesSnapshot
:
vscode
.
SourceControlResourceState
[]
=
[];
get
id
():
string
{
return
this
.
_id
;
}
get
id
():
string
{
return
this
.
_id
;
}
get
label
():
string
{
return
this
.
_label
;
}
get
label
():
string
{
return
this
.
_label
;
}
...
@@ -94,43 +114,61 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
...
@@ -94,43 +114,61 @@ class ExtHostSourceControlResourceGroup implements vscode.SourceControlResourceG
this
.
_onDidUpdateResourceStates
.
fire
();
this
.
_onDidUpdateResourceStates
.
fire
();
}
}
get
_rawResources
():
SCMRawResource
[]
{
_snapshot
():
SCMRawResourceSplice
[]
{
const
handles
:
number
[]
=
[];
const
original
=
new
ResourceSequence
(
this
.
_resourcesSnapshot
);
const
rawResources
=
this
.
_resourceStates
.
map
(
r
=>
{
const
modified
=
new
ResourceSequence
(
this
.
_resourceStates
);
const
handle
=
this
.
_resourceHandlePool
++
;
const
lcs
=
new
LcsDiff
(
original
,
modified
);
this
.
_resourceStatesMap
.
set
(
handle
,
r
);
const
diffs
=
lcs
.
ComputeDiff
(
false
);
handles
.
push
(
handle
);
const
handlesToDelete
:
number
[]
=
[];
const
splices
=
diffs
.
map
(
diff
=>
{
const
start
=
diff
.
originalStart
;
const
deleteCount
=
diff
.
originalLength
;
const
handles
:
number
[]
=
[];
const
rawResources
=
this
.
_resourceStates
.
slice
(
diff
.
modifiedStart
,
diff
.
modifiedStart
+
diff
.
modifiedLength
)
.
map
(
r
=>
{
const
handle
=
this
.
_resourceHandlePool
++
;
this
.
_resourceStatesMap
.
set
(
handle
,
r
);
handles
.
push
(
handle
);
const
sourceUri
=
r
.
resourceUri
.
toString
();
const
command
=
this
.
_commands
.
toInternal
(
r
.
command
);
const
iconPath
=
getIconPath
(
r
.
decorations
);
const
lightIconPath
=
r
.
decorations
&&
getIconPath
(
r
.
decorations
.
light
)
||
iconPath
;
const
darkIconPath
=
r
.
decorations
&&
getIconPath
(
r
.
decorations
.
dark
)
||
iconPath
;
const
icons
:
string
[]
=
[];
if
(
lightIconPath
||
darkIconPath
)
{
icons
.
push
(
lightIconPath
);
}
const
sourceUri
=
r
.
resourceUri
.
toString
();
if
(
darkIconPath
!==
lightIconPath
)
{
const
command
=
this
.
_commands
.
toInternal
(
r
.
command
);
icons
.
push
(
darkIconPath
);
const
iconPath
=
getIconPath
(
r
.
decorations
);
}
const
lightIconPath
=
r
.
decorations
&&
getIconPath
(
r
.
decorations
.
light
)
||
iconPath
;
const
darkIconPath
=
r
.
decorations
&&
getIconPath
(
r
.
decorations
.
dark
)
||
iconPath
;
const
icons
:
string
[]
=
[];
if
(
lightIconPath
||
darkIconPath
)
{
const
tooltip
=
(
r
.
decorations
&&
r
.
decorations
.
tooltip
)
||
''
;
icons
.
push
(
lightIconPath
)
;
const
strikeThrough
=
r
.
decorations
&&
!!
r
.
decorations
.
strikeThrough
;
}
const
faded
=
r
.
decorations
&&
!!
r
.
decorations
.
faded
;
if
(
darkIconPath
!==
lightIconPath
)
{
return
[
handle
,
sourceUri
,
command
,
icons
,
tooltip
,
strikeThrough
,
faded
]
as
SCMRawResource
;
icons
.
push
(
darkIconPath
);
});
}
const
tooltip
=
(
r
.
decorations
&&
r
.
decorations
.
tooltip
)
||
''
;
handlesToDelete
.
push
(...
this
.
_handlesSnapshot
.
splice
(
start
,
deleteCount
,
...
handles
));
const
strikeThrough
=
r
.
decorations
&&
!!
r
.
decorations
.
strikeThrough
;
const
faded
=
r
.
decorations
&&
!!
r
.
decorations
.
faded
;
return
[
handle
,
sourceUri
,
command
,
icons
,
tooltip
,
strikeThrough
,
faded
]
as
SCMRawResour
ce
;
return
[
start
,
deleteCount
,
rawResources
]
as
SCMRawResourceSpli
ce
;
});
});
const
disposable
=
()
=>
handles
.
forEach
(
handle
=>
this
.
_resourceStatesMap
.
delete
(
handle
));
const
disposable
=
()
=>
handles
ToDelete
.
forEach
(
handle
=>
this
.
_resourceStatesMap
.
delete
(
handle
));
this
.
_resourceStatesRollingDisposables
.
push
(
disposable
);
this
.
_resourceStatesRollingDisposables
.
push
(
disposable
);
while
(
this
.
_resourceStatesRollingDisposables
.
length
>=
10
)
{
while
(
this
.
_resourceStatesRollingDisposables
.
length
>=
10
)
{
this
.
_resourceStatesRollingDisposables
.
shift
()();
this
.
_resourceStatesRollingDisposables
.
shift
()();
}
}
return
rawResources
;
this
.
_resourcesSnapshot
=
this
.
_resourceStates
;
return
splices
;
}
}
readonly
handle
=
ExtHostSourceControlResourceGroup
.
_handlePool
++
;
readonly
handle
=
ExtHostSourceControlResourceGroup
.
_handlePool
++
;
...
@@ -266,12 +304,12 @@ class ExtHostSourceControl implements vscode.SourceControl {
...
@@ -266,12 +304,12 @@ class ExtHostSourceControl implements vscode.SourceControl {
@
debounce
(
100
)
@
debounce
(
100
)
eventuallyUpdateResourceStates
():
void
{
eventuallyUpdateResourceStates
():
void
{
const
resources
:
SCMRawResource
Group
[]
=
[];
const
resources
:
SCMRawResource
Splices
[]
=
[];
this
.
updatedResourceGroups
this
.
updatedResourceGroups
.
forEach
(
group
=>
resources
.
push
([
group
.
handle
,
group
.
_
rawResources
]));
.
forEach
(
group
=>
resources
.
push
([
group
.
handle
,
group
.
_
snapshot
()
]));
this
.
_proxy
.
$
updat
eResourceStates
(
this
.
handle
,
resources
);
this
.
_proxy
.
$
splic
eResourceStates
(
this
.
handle
,
resources
);
this
.
updatedResourceGroups
.
clear
();
this
.
updatedResourceGroups
.
clear
();
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录