Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ccfcbe6c
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
ccfcbe6c
编写于
3月 29, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
scm: move from pull to push model
上级
12470dcc
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
595 addition
and
484 deletion
+595
-484
extensions/git/package.json
extensions/git/package.json
+65
-65
extensions/git/src/commands.ts
extensions/git/src/commands.ts
+22
-31
extensions/git/src/main.ts
extensions/git/src/main.ts
+2
-2
extensions/git/src/merge.ts
extensions/git/src/merge.ts
+1
-1
extensions/git/src/model.ts
extensions/git/src/model.ts
+28
-50
extensions/git/src/scmProvider.ts
extensions/git/src/scmProvider.ts
+40
-10
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+96
-110
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+11
-11
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+19
-19
src/vs/workbench/api/node/extHostSCM.ts
src/vs/workbench/api/node/extHostSCM.ts
+139
-79
src/vs/workbench/api/node/mainThreadSCM.ts
src/vs/workbench/api/node/mainThreadSCM.ts
+158
-89
src/vs/workbench/parts/git/browser/gitScm.ts
src/vs/workbench/parts/git/browser/gitScm.ts
+2
-2
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
+6
-2
src/vs/workbench/services/scm/common/scm.ts
src/vs/workbench/services/scm/common/scm.ts
+6
-5
src/vs/workbench/services/scm/common/scmService.ts
src/vs/workbench/services/scm/common/scmService.ts
+0
-8
未找到文件。
extensions/git/package.json
浏览文件 @
ccfcbe6c
...
@@ -220,305 +220,305 @@
...
@@ -220,305 +220,305 @@
},
},
{
{
"command"
:
"git.init"
,
"command"
:
"git.init"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == norepo"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == norepo"
},
},
{
{
"command"
:
"git.refresh"
,
"command"
:
"git.refresh"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.openChange"
,
"command"
:
"git.openChange"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.openFile"
,
"command"
:
"git.openFile"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.stage"
,
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.stageAll"
,
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.stageSelectedRanges"
,
"command"
:
"git.stageSelectedRanges"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.revertSelectedRanges"
,
"command"
:
"git.revertSelectedRanges"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.unstage"
,
"command"
:
"git.unstage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.unstageAll"
,
"command"
:
"git.unstageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.unstageSelectedRanges"
,
"command"
:
"git.unstageSelectedRanges"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.clean"
,
"command"
:
"git.clean"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.cleanAll"
,
"command"
:
"git.cleanAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.commit"
,
"command"
:
"git.commit"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.commitStaged"
,
"command"
:
"git.commitStaged"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.commitStagedSigned"
,
"command"
:
"git.commitStagedSigned"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.commitAll"
,
"command"
:
"git.commitAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.commitAllSigned"
,
"command"
:
"git.commitAllSigned"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.undoCommit"
,
"command"
:
"git.undoCommit"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.checkout"
,
"command"
:
"git.checkout"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.branch"
,
"command"
:
"git.branch"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.pull"
,
"command"
:
"git.pull"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.pullRebase"
,
"command"
:
"git.pullRebase"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.push"
,
"command"
:
"git.push"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.pushTo"
,
"command"
:
"git.pushTo"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.sync"
,
"command"
:
"git.sync"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.publish"
,
"command"
:
"git.publish"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.showOutput"
,
"command"
:
"git.showOutput"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
}
}
],
],
"scm/title"
:
[
"scm/title"
:
[
{
{
"command"
:
"git.init"
,
"command"
:
"git.init"
,
"group"
:
"navigation"
,
"group"
:
"navigation"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == norepo"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == norepo"
},
},
{
{
"command"
:
"git.commit"
,
"command"
:
"git.commit"
,
"group"
:
"navigation"
,
"group"
:
"navigation"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.refresh"
,
"command"
:
"git.refresh"
,
"group"
:
"navigation"
,
"group"
:
"navigation"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.sync"
,
"command"
:
"git.sync"
,
"group"
:
"1_sync"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.pull"
,
"command"
:
"git.pull"
,
"group"
:
"1_sync"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.pullRebase"
,
"command"
:
"git.pullRebase"
,
"group"
:
"1_sync"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.push"
,
"command"
:
"git.push"
,
"group"
:
"1_sync"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.pushTo"
,
"command"
:
"git.pushTo"
,
"group"
:
"1_sync"
,
"group"
:
"1_sync"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.publish"
,
"command"
:
"git.publish"
,
"group"
:
"2_publish"
,
"group"
:
"2_publish"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.commitStaged"
,
"command"
:
"git.commitStaged"
,
"group"
:
"3_commit"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.commitStagedSigned"
,
"command"
:
"git.commitStagedSigned"
,
"group"
:
"3_commit"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.commitAll"
,
"command"
:
"git.commitAll"
,
"group"
:
"3_commit"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.commitAllSigned"
,
"command"
:
"git.commitAllSigned"
,
"group"
:
"3_commit"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.undoCommit"
,
"command"
:
"git.undoCommit"
,
"group"
:
"3_commit"
,
"group"
:
"3_commit"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.unstageAll"
,
"command"
:
"git.unstageAll"
,
"group"
:
"4_stage"
,
"group"
:
"4_stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.cleanAll"
,
"command"
:
"git.cleanAll"
,
"group"
:
"4_stage"
,
"group"
:
"4_stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
},
},
{
{
"command"
:
"git.showOutput"
,
"command"
:
"git.showOutput"
,
"group"
:
"5_output"
,
"group"
:
"5_output"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle"
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle"
}
}
],
],
"scm/resourceGroup/context"
:
[
"scm/resourceGroup/context"
:
[
{
{
"command"
:
"git.stageAll"
,
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == merge"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == merge"
,
"group"
:
"1_modification"
"group"
:
"1_modification"
},
},
{
{
"command"
:
"git.stageAll"
,
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == merge"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == merge"
,
"group"
:
"inline"
"group"
:
"inline"
},
},
{
{
"command"
:
"git.unstageAll"
,
"command"
:
"git.unstageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == index"
,
"group"
:
"1_modification"
"group"
:
"1_modification"
},
},
{
{
"command"
:
"git.unstageAll"
,
"command"
:
"git.unstageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == index"
,
"group"
:
"inline"
"group"
:
"inline"
},
},
{
{
"command"
:
"git.cleanAll"
,
"command"
:
"git.cleanAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"1_modification"
"group"
:
"1_modification"
},
},
{
{
"command"
:
"git.stageAll"
,
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"1_modification"
"group"
:
"1_modification"
},
},
{
{
"command"
:
"git.cleanAll"
,
"command"
:
"git.cleanAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"inline"
"group"
:
"inline"
},
},
{
{
"command"
:
"git.stageAll"
,
"command"
:
"git.stageAll"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"inline"
"group"
:
"inline"
}
}
],
],
"scm/resource/context"
:
[
"scm/resource/context"
:
[
{
{
"command"
:
"git.stage"
,
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == merge"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == merge"
,
"group"
:
"1_modification"
"group"
:
"1_modification"
},
},
{
{
"command"
:
"git.stage"
,
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == merge"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == merge"
,
"group"
:
"inline"
"group"
:
"inline"
},
},
{
{
"command"
:
"git.openChange"
,
"command"
:
"git.openChange"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == index"
,
"group"
:
"navigation"
"group"
:
"navigation"
},
},
{
{
"command"
:
"git.openFile"
,
"command"
:
"git.openFile"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == index"
,
"group"
:
"navigation"
"group"
:
"navigation"
},
},
{
{
"command"
:
"git.unstage"
,
"command"
:
"git.unstage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == index"
,
"group"
:
"1_modification"
"group"
:
"1_modification"
},
},
{
{
"command"
:
"git.unstage"
,
"command"
:
"git.unstage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == index"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == index"
,
"group"
:
"inline"
"group"
:
"inline"
},
},
{
{
"command"
:
"git.openChange"
,
"command"
:
"git.openChange"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"navigation"
"group"
:
"navigation"
},
},
{
{
"command"
:
"git.openFile"
,
"command"
:
"git.openFile"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"navigation"
"group"
:
"navigation"
},
},
{
{
"command"
:
"git.stage"
,
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"1_modification"
"group"
:
"1_modification"
},
},
{
{
"command"
:
"git.clean"
,
"command"
:
"git.clean"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"1_modification"
"group"
:
"1_modification"
},
},
{
{
"command"
:
"git.clean"
,
"command"
:
"git.clean"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"inline"
"group"
:
"inline"
},
},
{
{
"command"
:
"git.stage"
,
"command"
:
"git.stage"
,
"when"
:
"config.git.enabled && scmProvider == git &&
scmProvider
State == idle && scmResourceGroup == workingTree"
,
"when"
:
"config.git.enabled && scmProvider == git &&
git
State == idle && scmResourceGroup == workingTree"
,
"group"
:
"inline"
"group"
:
"inline"
}
}
],
],
...
...
extensions/git/src/commands.ts
浏览文件 @
ccfcbe6c
...
@@ -112,7 +112,12 @@ export class CommandCenter {
...
@@ -112,7 +112,12 @@ export class CommandCenter {
await
this
.
model
.
status
();
await
this
.
model
.
status
();
}
}
async
open
(
resource
:
Resource
):
Promise
<
void
>
{
@
command
(
'
git.openResource
'
)
async
openResource
(
resource
:
Resource
):
Promise
<
void
>
{
await
this
.
_openResource
(
resource
);
}
private
async
_openResource
(
resource
:
Resource
):
Promise
<
void
>
{
const
left
=
this
.
getLeftResource
(
resource
);
const
left
=
this
.
getLeftResource
(
resource
);
const
right
=
this
.
getRightResource
(
resource
);
const
right
=
this
.
getRightResource
(
resource
);
const
title
=
this
.
getTitle
(
resource
);
const
title
=
this
.
getTitle
(
resource
);
...
@@ -137,7 +142,7 @@ export class CommandCenter {
...
@@ -137,7 +142,7 @@ export class CommandCenter {
return
resource
.
original
.
with
({
scheme
:
'
git
'
,
query
:
'
HEAD
'
});
return
resource
.
original
.
with
({
scheme
:
'
git
'
,
query
:
'
HEAD
'
});
case
Status
.
MODIFIED
:
case
Status
.
MODIFIED
:
return
resource
.
sourceUri
.
with
({
scheme
:
'
git
'
,
query
:
'
~
'
});
return
resource
.
re
sourceUri
.
with
({
scheme
:
'
git
'
,
query
:
'
~
'
});
}
}
}
}
...
@@ -146,34 +151,34 @@ export class CommandCenter {
...
@@ -146,34 +151,34 @@ export class CommandCenter {
case
Status
.
INDEX_MODIFIED
:
case
Status
.
INDEX_MODIFIED
:
case
Status
.
INDEX_ADDED
:
case
Status
.
INDEX_ADDED
:
case
Status
.
INDEX_COPIED
:
case
Status
.
INDEX_COPIED
:
return
resource
.
sourceUri
.
with
({
scheme
:
'
git
'
});
return
resource
.
re
sourceUri
.
with
({
scheme
:
'
git
'
});
case
Status
.
INDEX_RENAMED
:
case
Status
.
INDEX_RENAMED
:
return
resource
.
sourceUri
.
with
({
scheme
:
'
git
'
});
return
resource
.
re
sourceUri
.
with
({
scheme
:
'
git
'
});
case
Status
.
INDEX_DELETED
:
case
Status
.
INDEX_DELETED
:
case
Status
.
DELETED
:
case
Status
.
DELETED
:
return
resource
.
sourceUri
.
with
({
scheme
:
'
git
'
,
query
:
'
HEAD
'
});
return
resource
.
re
sourceUri
.
with
({
scheme
:
'
git
'
,
query
:
'
HEAD
'
});
case
Status
.
MODIFIED
:
case
Status
.
MODIFIED
:
case
Status
.
UNTRACKED
:
case
Status
.
UNTRACKED
:
case
Status
.
IGNORED
:
case
Status
.
IGNORED
:
const
uriString
=
resource
.
sourceUri
.
toString
();
const
uriString
=
resource
.
re
sourceUri
.
toString
();
const
[
indexStatus
]
=
this
.
model
.
indexGroup
.
resources
.
filter
(
r
=>
r
.
sourceUri
.
toString
()
===
uriString
);
const
[
indexStatus
]
=
this
.
model
.
indexGroup
.
resources
.
filter
(
r
=>
r
.
re
sourceUri
.
toString
()
===
uriString
);
if
(
indexStatus
&&
indexStatus
.
rename
)
{
if
(
indexStatus
&&
indexStatus
.
rename
ResourceUri
)
{
return
indexStatus
.
rename
;
return
indexStatus
.
rename
ResourceUri
;
}
}
return
resource
.
sourceUri
;
return
resource
.
re
sourceUri
;
case
Status
.
BOTH_MODIFIED
:
case
Status
.
BOTH_MODIFIED
:
return
resource
.
sourceUri
;
return
resource
.
re
sourceUri
;
}
}
}
}
private
getTitle
(
resource
:
Resource
):
string
{
private
getTitle
(
resource
:
Resource
):
string
{
const
basename
=
path
.
basename
(
resource
.
sourceUri
.
fsPath
);
const
basename
=
path
.
basename
(
resource
.
re
sourceUri
.
fsPath
);
switch
(
resource
.
type
)
{
switch
(
resource
.
type
)
{
case
Status
.
INDEX_MODIFIED
:
case
Status
.
INDEX_MODIFIED
:
...
@@ -251,7 +256,7 @@ export class CommandCenter {
...
@@ -251,7 +256,7 @@ export class CommandCenter {
return
;
return
;
}
}
return
await
commands
.
executeCommand
<
void
>
(
'
vscode.open
'
,
resource
.
sourceUri
);
return
await
commands
.
executeCommand
<
void
>
(
'
vscode.open
'
,
resource
.
re
sourceUri
);
}
}
@
command
(
'
git.openChange
'
)
@
command
(
'
git.openChange
'
)
...
@@ -262,7 +267,7 @@ export class CommandCenter {
...
@@ -262,7 +267,7 @@ export class CommandCenter {
return
;
return
;
}
}
return
await
this
.
open
(
resource
);
return
await
this
.
_openResource
(
resource
);
}
}
@
command
(
'
git.stage
'
)
@
command
(
'
git.stage
'
)
...
@@ -426,7 +431,7 @@ export class CommandCenter {
...
@@ -426,7 +431,7 @@ export class CommandCenter {
}
}
const
message
=
resources
.
length
===
1
const
message
=
resources
.
length
===
1
?
localize
(
'
confirm discard
'
,
"
Are you sure you want to discard changes in {0}?
"
,
path
.
basename
(
resources
[
0
].
sourceUri
.
fsPath
))
?
localize
(
'
confirm discard
'
,
"
Are you sure you want to discard changes in {0}?
"
,
path
.
basename
(
resources
[
0
].
re
sourceUri
.
fsPath
))
:
localize
(
'
confirm discard multiple
'
,
"
Are you sure you want to discard changes in {0} files?
"
,
resources
.
length
);
:
localize
(
'
confirm discard multiple
'
,
"
Are you sure you want to discard changes in {0} files?
"
,
resources
.
length
);
const
yes
=
localize
(
'
discard
'
,
"
Discard Changes
"
);
const
yes
=
localize
(
'
discard
'
,
"
Discard Changes
"
);
...
@@ -769,20 +774,6 @@ export class CommandCenter {
...
@@ -769,20 +774,6 @@ export class CommandCenter {
return
undefined
;
return
undefined
;
}
}
if
(
uri
.
scheme
===
'
git-resource
'
)
{
const
{
resourceGroupId
}
=
JSON
.
parse
(
uri
.
query
)
as
{
resourceGroupId
:
string
,
sourceUri
:
string
};
const
[
resourceGroup
]
=
this
.
model
.
resources
.
filter
(
g
=>
g
.
contextKey
===
resourceGroupId
);
if
(
!
resourceGroup
)
{
return
;
}
const
uriStr
=
uri
.
toString
();
const
[
resource
]
=
resourceGroup
.
resources
.
filter
(
r
=>
r
.
uri
.
toString
()
===
uriStr
);
return
resource
;
}
if
(
uri
.
scheme
===
'
git
'
)
{
if
(
uri
.
scheme
===
'
git
'
)
{
uri
=
uri
.
with
({
scheme
:
'
file
'
});
uri
=
uri
.
with
({
scheme
:
'
file
'
});
}
}
...
@@ -790,8 +781,8 @@ export class CommandCenter {
...
@@ -790,8 +781,8 @@ export class CommandCenter {
if
(
uri
.
scheme
===
'
file
'
)
{
if
(
uri
.
scheme
===
'
file
'
)
{
const
uriString
=
uri
.
toString
();
const
uriString
=
uri
.
toString
();
return
this
.
model
.
workingTreeGroup
.
resources
.
filter
(
r
=>
r
.
sourceUri
.
toString
()
===
uriString
)[
0
]
return
this
.
model
.
workingTreeGroup
.
resources
.
filter
(
r
=>
r
.
re
sourceUri
.
toString
()
===
uriString
)[
0
]
||
this
.
model
.
indexGroup
.
resources
.
filter
(
r
=>
r
.
sourceUri
.
toString
()
===
uriString
)[
0
];
||
this
.
model
.
indexGroup
.
resources
.
filter
(
r
=>
r
.
re
sourceUri
.
toString
()
===
uriString
)[
0
];
}
}
}
}
...
...
extensions/git/src/main.ts
浏览文件 @
ccfcbe6c
...
@@ -78,10 +78,10 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
...
@@ -78,10 +78,10 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
}
}
}
}
filterEvent
(
scm
.
onDidAcceptInputValue
,
()
=>
scm
.
active
Provider
===
provider
)
filterEvent
(
scm
.
onDidAcceptInputValue
,
()
=>
scm
.
active
SourceControl
===
provider
.
sourceControl
)
(
commandCenter
.
commitWithInput
,
commandCenter
,
disposables
);
(
commandCenter
.
commitWithInput
,
commandCenter
,
disposables
);
if
(
scm
.
active
Provider
===
provider
)
{
if
(
scm
.
active
SourceControl
===
provider
.
sourceControl
)
{
scm
.
inputBox
.
value
=
await
model
.
getCommitTemplate
();
scm
.
inputBox
.
value
=
await
model
.
getCommitTemplate
();
}
}
}
}
...
...
extensions/git/src/merge.ts
浏览文件 @
ccfcbe6c
...
@@ -62,7 +62,7 @@ class TextEditorMergeDecorator {
...
@@ -62,7 +62,7 @@ class TextEditorMergeDecorator {
return
;
return
;
}
}
if
(
this
.
model
.
mergeGroup
.
resources
.
some
(
r
=>
r
.
type
===
Status
.
BOTH_MODIFIED
&&
r
.
sourceUri
.
toString
()
===
this
.
uri
))
{
if
(
this
.
model
.
mergeGroup
.
resources
.
some
(
r
=>
r
.
type
===
Status
.
BOTH_MODIFIED
&&
r
.
re
sourceUri
.
toString
()
===
this
.
uri
))
{
decorations
=
decorate
(
this
.
editor
.
document
);
decorations
=
decorate
(
this
.
editor
.
document
);
}
}
...
...
extensions/git/src/model.ts
浏览文件 @
ccfcbe6c
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
'
use strict
'
;
'
use strict
'
;
import
{
Uri
,
EventEmitter
,
Event
,
SCMResource
,
SCMResourceDecorations
,
SCMResourceGroup
,
Disposable
,
window
,
workspace
}
from
'
vscode
'
;
import
{
Uri
,
Command
,
EventEmitter
,
Event
,
SourceControlResourceState
,
SourceControlResourceDecorations
,
Disposable
,
window
,
workspace
}
from
'
vscode
'
;
import
{
Git
,
Repository
,
Ref
,
Branch
,
Remote
,
PushOptions
,
Commit
,
GitErrorCodes
,
GitError
}
from
'
./git
'
;
import
{
Git
,
Repository
,
Ref
,
Branch
,
Remote
,
PushOptions
,
Commit
,
GitErrorCodes
,
GitError
}
from
'
./git
'
;
import
{
anyEvent
,
eventToPromise
,
filterEvent
,
mapEvent
,
EmptyDisposable
,
combinedDisposable
,
dispose
}
from
'
./util
'
;
import
{
anyEvent
,
eventToPromise
,
filterEvent
,
mapEvent
,
EmptyDisposable
,
combinedDisposable
,
dispose
}
from
'
./util
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
import
{
memoize
,
throttle
,
debounce
}
from
'
./decorators
'
;
...
@@ -51,31 +51,29 @@ export enum Status {
...
@@ -51,31 +51,29 @@ export enum Status {
BOTH_MODIFIED
BOTH_MODIFIED
}
}
export
class
Resource
implements
S
CMResourc
e
{
export
class
Resource
implements
S
ourceControlResourceStat
e
{
@
memoize
@
memoize
get
uri
():
Uri
{
get
resourceUri
():
Uri
{
return
new
Uri
().
with
({
if
(
this
.
renameResourceUri
&&
(
this
.
_type
===
Status
.
MODIFIED
||
this
.
_type
===
Status
.
DELETED
||
this
.
_type
===
Status
.
INDEX_RENAMED
))
{
scheme
:
'
git-resource
'
,
return
this
.
renameResourceUri
;
query
:
JSON
.
stringify
({
}
resourceGroupId
:
this
.
resourceGroupId
,
sourceUri
:
this
.
sourceUri
.
toString
()
return
this
.
_resourceUri
;
})
});
}
}
@
memoize
@
memoize
get
sourceUri
():
Uri
{
get
command
():
Command
{
if
(
this
.
rename
&&
(
this
.
_type
===
Status
.
MODIFIED
||
this
.
_type
===
Status
.
DELETED
||
this
.
_type
===
Status
.
INDEX_RENAMED
))
{
return
{
return
this
.
rename
;
command
:
'
git.openResource
'
,
}
title
:
localize
(
'
open
'
,
"
Open
"
),
arguments
:
[
this
]
return
this
.
_sourceUri
;
}
;
}
}
get
type
():
Status
{
return
this
.
_type
;
}
get
type
():
Status
{
return
this
.
_type
;
}
get
original
():
Uri
{
return
this
.
_sourceUri
;
}
get
original
():
Uri
{
return
this
.
_
re
sourceUri
;
}
get
rename
():
Uri
|
undefined
{
return
this
.
_rename
;
}
get
rename
ResourceUri
():
Uri
|
undefined
{
return
this
.
_renameResourceUri
;
}
private
static
Icons
=
{
private
static
Icons
=
{
light
:
{
light
:
{
...
@@ -134,23 +132,19 @@ export class Resource implements SCMResource {
...
@@ -134,23 +132,19 @@ export class Resource implements SCMResource {
}
}
}
}
get
decorations
():
S
CM
ResourceDecorations
{
get
decorations
():
S
ourceControl
ResourceDecorations
{
const
light
=
{
iconPath
:
this
.
getIconPath
(
'
light
'
)
};
const
light
=
{
iconPath
:
this
.
getIconPath
(
'
light
'
)
};
const
dark
=
{
iconPath
:
this
.
getIconPath
(
'
dark
'
)
};
const
dark
=
{
iconPath
:
this
.
getIconPath
(
'
dark
'
)
};
return
{
strikeThrough
:
this
.
strikeThrough
,
light
,
dark
};
return
{
strikeThrough
:
this
.
strikeThrough
,
light
,
dark
};
}
}
constructor
(
private
resourceGroupId
:
string
,
private
_sourceUri
:
Uri
,
private
_type
:
Status
,
private
_rename
?:
Uri
)
{
constructor
(
private
resourceGroupId
:
string
,
private
_resourceUri
:
Uri
,
private
_type
:
Status
,
private
_renameResourceUri
?:
Uri
)
{
}
// console.log(this);
}
}
}
export
class
ResourceGroup
implements
SCMResourceGroup
{
export
class
ResourceGroup
{
@
memoize
get
uri
():
Uri
{
return
Uri
.
parse
(
`git-resource-group:
${
this
.
contextKey
}
`
);
}
get
id
():
string
{
return
this
.
_id
;
}
get
contextKey
():
string
{
return
this
.
_id
;
}
get
contextKey
():
string
{
return
this
.
_id
;
}
get
label
():
string
{
return
this
.
_label
;
}
get
label
():
string
{
return
this
.
_label
;
}
get
resources
():
Resource
[]
{
return
this
.
_resources
;
}
get
resources
():
Resource
[]
{
return
this
.
_resources
;
}
...
@@ -280,8 +274,8 @@ export class Model implements Disposable {
...
@@ -280,8 +274,8 @@ export class Model implements Disposable {
private
_onDidChangeState
=
new
EventEmitter
<
State
>
();
private
_onDidChangeState
=
new
EventEmitter
<
State
>
();
readonly
onDidChangeState
:
Event
<
State
>
=
this
.
_onDidChangeState
.
event
;
readonly
onDidChangeState
:
Event
<
State
>
=
this
.
_onDidChangeState
.
event
;
private
_onDidChangeResources
=
new
EventEmitter
<
SCMResourceGroup
[]
>
();
private
_onDidChangeResources
=
new
EventEmitter
<
void
>
();
readonly
onDidChangeResources
:
Event
<
SCMResourceGroup
[]
>
=
this
.
_onDidChangeResources
.
event
;
readonly
onDidChangeResources
:
Event
<
void
>
=
this
.
_onDidChangeResources
.
event
;
@
memoize
@
memoize
get
onDidChange
():
Event
<
void
>
{
get
onDidChange
():
Event
<
void
>
{
...
@@ -308,22 +302,6 @@ export class Model implements Disposable {
...
@@ -308,22 +302,6 @@ export class Model implements Disposable {
private
_workingTreeGroup
=
new
WorkingTreeGroup
([]);
private
_workingTreeGroup
=
new
WorkingTreeGroup
([]);
get
workingTreeGroup
():
WorkingTreeGroup
{
return
this
.
_workingTreeGroup
;
}
get
workingTreeGroup
():
WorkingTreeGroup
{
return
this
.
_workingTreeGroup
;
}
get
resources
():
ResourceGroup
[]
{
const
result
:
ResourceGroup
[]
=
[];
if
(
this
.
_mergeGroup
.
resources
.
length
>
0
)
{
result
.
push
(
this
.
_mergeGroup
);
}
if
(
this
.
_indexGroup
.
resources
.
length
>
0
)
{
result
.
push
(
this
.
_indexGroup
);
}
result
.
push
(
this
.
_workingTreeGroup
);
return
result
;
}
private
_HEAD
:
Branch
|
undefined
;
private
_HEAD
:
Branch
|
undefined
;
get
HEAD
():
Branch
|
undefined
{
get
HEAD
():
Branch
|
undefined
{
return
this
.
_HEAD
;
return
this
.
_HEAD
;
...
@@ -356,7 +334,7 @@ export class Model implements Disposable {
...
@@ -356,7 +334,7 @@ export class Model implements Disposable {
this
.
_mergeGroup
=
new
MergeGroup
();
this
.
_mergeGroup
=
new
MergeGroup
();
this
.
_indexGroup
=
new
IndexGroup
();
this
.
_indexGroup
=
new
IndexGroup
();
this
.
_workingTreeGroup
=
new
WorkingTreeGroup
();
this
.
_workingTreeGroup
=
new
WorkingTreeGroup
();
this
.
_onDidChangeResources
.
fire
(
this
.
resources
);
this
.
_onDidChangeResources
.
fire
();
}
}
private
onWorkspaceChange
:
Event
<
Uri
>
;
private
onWorkspaceChange
:
Event
<
Uri
>
;
...
@@ -412,7 +390,7 @@ export class Model implements Disposable {
...
@@ -412,7 +390,7 @@ export class Model implements Disposable {
@
throttle
@
throttle
async
add
(...
resources
:
Resource
[]):
Promise
<
void
>
{
async
add
(...
resources
:
Resource
[]):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
Add
,
()
=>
this
.
repository
.
add
(
resources
.
map
(
r
=>
r
.
sourceUri
.
fsPath
)));
await
this
.
run
(
Operation
.
Add
,
()
=>
this
.
repository
.
add
(
resources
.
map
(
r
=>
r
.
re
sourceUri
.
fsPath
)));
}
}
@
throttle
@
throttle
...
@@ -423,7 +401,7 @@ export class Model implements Disposable {
...
@@ -423,7 +401,7 @@ export class Model implements Disposable {
@
throttle
@
throttle
async
revertFiles
(...
resources
:
Resource
[]):
Promise
<
void
>
{
async
revertFiles
(...
resources
:
Resource
[]):
Promise
<
void
>
{
await
this
.
run
(
Operation
.
RevertFiles
,
()
=>
this
.
repository
.
revertFiles
(
'
HEAD
'
,
resources
.
map
(
r
=>
r
.
sourceUri
.
fsPath
)));
await
this
.
run
(
Operation
.
RevertFiles
,
()
=>
this
.
repository
.
revertFiles
(
'
HEAD
'
,
resources
.
map
(
r
=>
r
.
re
sourceUri
.
fsPath
)));
}
}
@
throttle
@
throttle
...
@@ -447,11 +425,11 @@ export class Model implements Disposable {
...
@@ -447,11 +425,11 @@ export class Model implements Disposable {
switch
(
r
.
type
)
{
switch
(
r
.
type
)
{
case
Status
.
UNTRACKED
:
case
Status
.
UNTRACKED
:
case
Status
.
IGNORED
:
case
Status
.
IGNORED
:
toClean
.
push
(
r
.
sourceUri
.
fsPath
);
toClean
.
push
(
r
.
re
sourceUri
.
fsPath
);
break
;
break
;
default
:
default
:
toCheckout
.
push
(
r
.
sourceUri
.
fsPath
);
toCheckout
.
push
(
r
.
re
sourceUri
.
fsPath
);
break
;
break
;
}
}
});
});
...
@@ -671,7 +649,7 @@ export class Model implements Disposable {
...
@@ -671,7 +649,7 @@ export class Model implements Disposable {
this
.
_mergeGroup
=
new
MergeGroup
(
merge
);
this
.
_mergeGroup
=
new
MergeGroup
(
merge
);
this
.
_indexGroup
=
new
IndexGroup
(
index
);
this
.
_indexGroup
=
new
IndexGroup
(
index
);
this
.
_workingTreeGroup
=
new
WorkingTreeGroup
(
workingTree
);
this
.
_workingTreeGroup
=
new
WorkingTreeGroup
(
workingTree
);
this
.
_onDidChangeResources
.
fire
(
this
.
resources
);
this
.
_onDidChangeResources
.
fire
();
}
}
private
onFSChange
(
uri
:
Uri
):
void
{
private
onFSChange
(
uri
:
Uri
):
void
{
...
...
extensions/git/src/scmProvider.ts
浏览文件 @
ccfcbe6c
...
@@ -5,17 +5,15 @@
...
@@ -5,17 +5,15 @@
'
use strict
'
;
'
use strict
'
;
import
{
scm
,
Uri
,
Disposable
,
S
CMProvider
,
SCMResourceGroup
,
Event
,
workspace
}
from
'
vscode
'
;
import
{
scm
,
Uri
,
Disposable
,
S
ourceControl
,
SourceControlResourceGroup
,
Event
,
workspace
,
commands
}
from
'
vscode
'
;
import
{
Model
,
Resource
,
State
}
from
'
./model
'
;
import
{
Model
,
State
}
from
'
./model
'
;
import
{
CommandCenter
}
from
'
./commands
'
;
import
{
CommandCenter
}
from
'
./commands
'
;
import
{
mapEvent
}
from
'
./util
'
;
import
{
mapEvent
}
from
'
./util
'
;
export
class
GitSCMProvider
implements
SCMProvider
{
export
class
GitSCMProvider
{
private
disposables
:
Disposable
[]
=
[];
private
disposables
:
Disposable
[]
=
[];
get
contextKey
():
string
{
return
'
git
'
;
}
get
contextKey
():
string
{
return
'
git
'
;
}
get
resources
():
SCMResourceGroup
[]
{
return
this
.
model
.
resources
;
}
get
onDidChange
():
Event
<
this
>
{
get
onDidChange
():
Event
<
this
>
{
return
mapEvent
(
this
.
model
.
onDidChange
,
()
=>
this
);
return
mapEvent
(
this
.
model
.
onDidChange
,
()
=>
this
);
...
@@ -38,16 +36,40 @@ export class GitSCMProvider implements SCMProvider {
...
@@ -38,16 +36,40 @@ export class GitSCMProvider implements SCMProvider {
switch
(
countBadge
)
{
switch
(
countBadge
)
{
case
'
off
'
:
return
0
;
case
'
off
'
:
return
0
;
case
'
tracked
'
:
return
this
.
model
.
indexGroup
.
resources
.
length
;
case
'
tracked
'
:
return
this
.
model
.
indexGroup
.
resources
.
length
;
default
:
return
this
.
model
.
resources
.
reduce
((
r
,
g
)
=>
r
+
g
.
resources
.
length
,
0
);
default
:
return
this
.
model
.
mergeGroup
.
resources
.
length
+
this
.
model
.
indexGroup
.
resources
.
length
+
this
.
model
.
workingTreeGroup
.
resources
.
length
;
}
}
}
}
constructor
(
private
model
:
Model
,
private
commandCenter
:
CommandCenter
)
{
private
_sourceControl
:
SourceControl
;
scm
.
registerSCMProvider
(
this
);
get
sourceControl
():
SourceControl
{
return
this
.
_sourceControl
;
}
}
open
(
resource
:
Resource
):
void
{
private
mergeGroup
:
SourceControlResourceGroup
;
this
.
commandCenter
.
open
(
resource
);
private
indexGroup
:
SourceControlResourceGroup
;
private
workingTreeGroup
:
SourceControlResourceGroup
;
constructor
(
private
model
:
Model
,
private
commandCenter
:
CommandCenter
)
{
this
.
_sourceControl
=
scm
.
createSourceControl
(
'
git
'
,
'
Git
'
);
this
.
_sourceControl
.
quickDiffProvider
=
this
;
this
.
disposables
.
push
(
this
.
_sourceControl
);
this
.
mergeGroup
=
this
.
_sourceControl
.
createResourceGroup
(
model
.
mergeGroup
.
id
,
model
.
mergeGroup
.
label
);
this
.
indexGroup
=
this
.
_sourceControl
.
createResourceGroup
(
model
.
indexGroup
.
id
,
model
.
indexGroup
.
label
);
this
.
workingTreeGroup
=
this
.
_sourceControl
.
createResourceGroup
(
model
.
workingTreeGroup
.
id
,
model
.
workingTreeGroup
.
label
);
this
.
mergeGroup
.
hideWhenEmpty
=
true
;
this
.
indexGroup
.
hideWhenEmpty
=
true
;
this
.
disposables
.
push
(
this
.
mergeGroup
);
this
.
disposables
.
push
(
this
.
indexGroup
);
this
.
disposables
.
push
(
this
.
workingTreeGroup
);
model
.
onDidChange
(
this
.
onDidModelChange
,
this
,
this
.
disposables
);
}
}
provideOriginalResource
(
uri
:
Uri
):
Uri
|
undefined
{
provideOriginalResource
(
uri
:
Uri
):
Uri
|
undefined
{
...
@@ -60,6 +82,14 @@ export class GitSCMProvider implements SCMProvider {
...
@@ -60,6 +82,14 @@ export class GitSCMProvider implements SCMProvider {
return
new
Uri
().
with
({
scheme
:
'
git-original
'
,
query
:
uri
.
path
,
path
:
uri
.
path
+
'
.git
'
});
return
new
Uri
().
with
({
scheme
:
'
git-original
'
,
query
:
uri
.
path
,
path
:
uri
.
path
+
'
.git
'
});
}
}
private
onDidModelChange
():
void
{
this
.
mergeGroup
.
resourceStates
=
this
.
model
.
mergeGroup
.
resources
;
this
.
indexGroup
.
resourceStates
=
this
.
model
.
indexGroup
.
resources
;
this
.
workingTreeGroup
.
resourceStates
=
this
.
model
.
workingTreeGroup
.
resources
;
this
.
_sourceControl
.
count
=
this
.
count
;
commands
.
executeCommand
(
'
setContext
'
,
'
gitState
'
,
this
.
stateContextKey
);
}
dispose
():
void
{
dispose
():
void
{
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
this
.
disposables
.
forEach
(
d
=>
d
.
dispose
());
this
.
disposables
=
[];
this
.
disposables
=
[];
...
...
src/vs/vscode.d.ts
浏览文件 @
ccfcbe6c
...
@@ -3857,8 +3857,8 @@ declare module 'vscode' {
...
@@ -3857,8 +3857,8 @@ declare module 'vscode' {
export
function
setStatusBarMessage
(
text
:
string
):
Disposable
;
export
function
setStatusBarMessage
(
text
:
string
):
Disposable
;
/**
/**
* Show progress in the
scm viewlet while running the given callback and while its returned
* Show progress in the
Source Control viewlet while running the given callback and while
* promise isn't resolve or rejected.
*
its returned
promise isn't resolve or rejected.
*
*
* @param task A callback returning a promise. Progress increments can be reported with
* @param task A callback returning a promise. Progress increments can be reported with
* the provided [progress](#Progress)-object.
* the provided [progress](#Progress)-object.
...
@@ -4539,208 +4539,194 @@ declare module 'vscode' {
...
@@ -4539,208 +4539,194 @@ declare module 'vscode' {
}
}
/**
/**
*
The theme-aware decorations for a [SCM resource](#SCMResource)
.
*
Represents the input box in the Source Control viewlet
.
*/
*/
export
interface
S
CMResourceThemableDecorations
{
export
interface
S
ourceControlInputBox
{
/**
/**
*
The icon path for a specific [SCM resource](#SCMResource)
.
*
Setter and getter for the contents of the input box
.
*/
*/
readonly
iconPath
?:
string
|
Uri
;
value
:
string
;
}
}
/**
interface
QuickDiffProvider
{
* The decorations for a [SCM resource](#SCMResource). Can be specified
* for light and dark themes, independently.
*/
export
interface
SCMResourceDecorations
extends
SCMResourceThemableDecorations
{
/**
/**
* Whether the [SCM resource](#SCMResource) should be striked-through
* Provide a [uri](#Uri) to the original resource of any given resource uri.
* in the UI.
*
* @param uri The uri of the resource open in a text editor.
* @param token A cancellation token.
* @return A thenable that resolves to uri of the matching original resource.
*/
*/
readonly
strikeThrough
?:
boolean
;
provideOriginalResource
?(
uri
:
Uri
,
token
:
CancellationToken
):
ProviderResult
<
Uri
>
;
}
/**
/**
* The light theme decorations.
* The theme-aware decorations for a
*/
* [source control resource state](#SourceControlResourceState).
readonly
light
?:
SCMResourceThemableDecorations
;
*/
export
interface
SourceControlResourceThemableDecorations
{
/**
/**
* The dark theme decorations.
* The icon path for a specific
* [source control resource state](#SourceControlResourceState).
*/
*/
readonly
dark
?:
SCMResourceThemableDecorations
;
readonly
iconPath
?:
string
|
Uri
;
}
}
/**
/**
*
An SCM resource represents the state of an underlying workspace
*
The decorations for a [source control resource state](#SourceControlResourceState).
*
resource within a certain SCM provider state
.
*
Can be independently specified for light and dark themes
.
*/
*/
export
interface
S
CMResource
{
export
interface
S
ourceControlResourceDecorations
extends
SourceControlResourceThemableDecorations
{
/**
/**
* The [uri](#Uri) of this SCM resource. This uri should uniquely
* Whether the [source control resource state](#SourceControlResourceState) should
* identify this SCM resource. Its value should be semantically
* be striked-through in the UI.
* related to your [SCM provider](#SCMProvider).
*
* For example, consider file `/foo/bar` to be modified. An SCM
* resource which would represent such state could have the
* following properties:
*
* - `uri = 'git:workingtree/A'`
* - `sourceUri = 'file:///foo/bar'`
*/
*/
readonly
uri
:
Uri
;
readonly
strikeThrough
?:
boolean
;
/**
/**
* The
[uri](#Uri) of the underlying resource inside the workspace
.
* The
light theme decorations
.
*/
*/
readonly
sourceUri
:
Uri
;
readonly
light
?:
SourceControlResourceThemableDecorations
;
/**
/**
* The
[decorations](#SCMResourceDecorations) for this SCM resource
.
* The
dark theme decorations
.
*/
*/
readonly
d
ecorations
?:
SCMResourc
eDecorations
;
readonly
d
ark
?:
SourceControlResourceThemabl
eDecorations
;
}
}
/**
/**
* An SCM resource group is a collection of [SCM resources](#SCMResource).
* An source control resource state represents the state of an underlying workspace
* resource within a certain [source control group](#SourceControlResourceGroup).
*/
*/
export
interface
S
CMResourceGroup
{
export
interface
S
ourceControlResourceState
{
/**
/**
* The [uri](#Uri) of this SCM resource group. This uri should
* The [uri](#Uri) of the underlying resource inside the workspace.
* uniquely identify this SCM resource group. Its value should be
* semantically related to your [SCM provider](#SCMProvider).
*
* For example, consider a Working Tree resource group. An SCM
* resource group which would represent such state could have the
* following properties:
*
* - `uri = 'git:workingtree'`
* - `label = 'Working Tree'`
*/
readonly
uri
:
Uri
;
/**
* The UI label of the SCM resource group.
*/
*/
readonly
label
:
string
;
readonly
resourceUri
:
Uri
;
/**
/**
* The
context key of the SCM resource group, which will be used to populat
e
* The
[command](#Command) which should be run when the resourc
e
*
the value of the `scmResourceGroup` context key
.
*
state is open in the Source Control viewlet
.
*/
*/
readonly
co
ntextKey
?:
string
;
readonly
co
mmand
:
Command
;
/**
/**
* The collection of [SCM resources](#SCMResource) within the SCM resource group.
* The [decorations](#SourceControlResourceDecorations) for this source control
* resource state.
*/
*/
readonly
resources
:
SCMResource
[]
;
readonly
decorations
?:
SourceControlResourceDecorations
;
}
}
/**
/**
* A
n SCM provider is able to provide [SCM resources](#SCMResource) to the editor,
* A
source control resource group is a collection of
*
notify of changes in them and interact with the editor in several SCM related ways
.
*
[source control resource states](#SourceControlResourceState)
.
*/
*/
export
interface
SCMProvider
{
export
interface
SourceControlResourceGroup
{
/**
* The id of this source control resource group.
*/
readonly
id
:
string
;
/**
/**
*
A human-readable label for the name of the SCM Provider
.
*
The label of this source control resource group
.
*/
*/
readonly
label
:
string
;
readonly
label
:
string
;
/**
/**
*
The context key of the SCM provider, which will be used to populate
*
Whether this source control resource group is hidden when it contains
*
the value of the `scmProvider` context key
.
*
no [source control resource states](#SourceControlResourceState)
.
*/
*/
readonly
contextKey
?:
string
;
hideWhenEmpty
?:
boolean
;
/**
/**
* The list of SCM resource groups.
* This group's collection of
* [source control resource states](#SourceControlResourceState).
*/
*/
re
adonly
resources
:
SCMResourceGroup
[];
re
sourceStates
:
SourceControlResourceState
[];
/**
/**
*
A count of resources, used in the UI as the label for the SCM changes count
.
*
Dispose this source control resource group
.
*/
*/
readonly
count
?:
number
;
dispose
():
void
;
}
/**
* An source control is able to provide [resource states](#SourceControlResourceState)
* to the editor and interact with the editor in several source control related ways.
*/
export
interface
SourceControl
{
/**
/**
* A state identifier, which will be used to populate the value of the
* The id of this source control.
* `scmProviderState` context key.
*/
*/
readonly
stateContextKey
?
:
string
;
readonly
id
:
string
;
/**
/**
* An [event](#Event) which should fire when any of the following attributes
* The human-readable label of this source control.
* have changed:
* - [resources](#SCMProvider.resources)
* - [count](#SCMProvider.count)
* - [state](#SCMProvider.state)
*/
*/
readonly
onDidChange
?:
Event
<
SCMProvider
>
;
readonly
label
:
string
;
/**
/**
* Provide a [uri](#Uri) to the original resource of any given resource uri.
* The UI-visible count of [resource states](#SourceControlResourceState) of
* this source control.
*
*
* @param uri The uri of the resource open in a text editor.
* Equals to the total number of [resource state](#SourceControlResourceState)
* @param token A cancellation token.
* of this source control, if undefined.
* @return A thenable that resolves to uri of the matching original resource.
*/
*/
provideOriginalResource
?(
uri
:
Uri
,
token
:
CancellationToken
):
ProviderResult
<
Uri
>
;
count
?:
number
;
/**
/**
* Open a specific [SCM resource](#SCMResource). Called when SCM resources
* An optional [quick diff provider](#QuickDiffProvider).
* are clicked in the UI, for example.
*
* @param resource The [SCM resource](#SCMResource) which should be open.
* @param token A cancellation token.
* @return A thenable which resolves when the resource is open.
*/
*/
open
?(
resource
:
SCMResource
):
void
;
quickDiffProvider
?:
QuickDiffProvider
;
}
/**
/**
* Represents the input box in the SCM view
.
* Create a new [resource group](#SourceControlResourceGroup)
.
*/
*/
export
interface
SCMInputBox
{
createResourceGroup
(
id
:
string
,
label
:
string
):
SourceControlResourceGroup
;
/**
/**
*
Setter and getter for the contents of the input box
.
*
Dispose this source control
.
*/
*/
value
:
string
;
dispose
():
void
;
}
}
export
namespace
scm
{
export
namespace
scm
{
/**
/**
* The currently active [
SCM provider](#SCMProvider
).
* The currently active [
source control](#SourceControl
).
*/
*/
export
let
active
Provider
:
SCMProvider
|
undefined
;
export
let
active
SourceControl
:
SourceControl
|
undefined
;
/**
/**
* An [event](#Event) which fires when the active [
SCM provider](#SCMProvider
)
* An [event](#Event) which fires when the active [
source control](#SourceControl
)
* has changed.
* has changed.
*/
*/
export
const
onDidChangeActive
Provider
:
Event
<
SCMProvider
>
;
export
const
onDidChangeActive
SourceControl
:
Event
<
SourceControl
>
;
/**
/**
* The [input box](#S
CMInputBox) in the SCM view
.
* The [input box](#S
ourceControlInputBox) in the Source Control viewlet
.
*/
*/
export
const
inputBox
:
S
CM
InputBox
;
export
const
inputBox
:
S
ourceControl
InputBox
;
/**
/**
* An [event](#Event) which fires when the user has accepted the changes.
* An [event](#Event) which fires when the user has accepted the changes.
*/
*/
export
const
onDidAcceptInputValue
:
Event
<
S
CM
InputBox
>
;
export
const
onDidAcceptInputValue
:
Event
<
S
ourceControl
InputBox
>
;
/**
/**
*
Registers an [SCM provider](#SCMProvider)
.
*
Creates a new [source control](#SourceControl) instance
.
*
*
* @return A disposable which unregisters the provider.
* @param id A unique `id` for the source control. Something short, eg: `git`.
* @param label A human-readable string for the source control. Eg: `Git`.
* @return An instance of [source control](#SourceControl).
*/
*/
export
function
registerSCMProvider
(
provider
:
SCMProvider
):
Disposable
;
export
function
createSourceControl
(
id
:
string
,
label
:
string
):
SourceControl
;
}
}
/**
/**
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
ccfcbe6c
...
@@ -117,7 +117,7 @@ export function createApiFactory(
...
@@ -117,7 +117,7 @@ export function createApiFactory(
const
extHostFileSystemEvent
=
col
.
define
(
ExtHostContext
.
ExtHostFileSystemEventService
).
set
<
ExtHostFileSystemEventService
>
(
new
ExtHostFileSystemEventService
());
const
extHostFileSystemEvent
=
col
.
define
(
ExtHostContext
.
ExtHostFileSystemEventService
).
set
<
ExtHostFileSystemEventService
>
(
new
ExtHostFileSystemEventService
());
const
extHostQuickOpen
=
col
.
define
(
ExtHostContext
.
ExtHostQuickOpen
).
set
<
ExtHostQuickOpen
>
(
new
ExtHostQuickOpen
(
threadService
));
const
extHostQuickOpen
=
col
.
define
(
ExtHostContext
.
ExtHostQuickOpen
).
set
<
ExtHostQuickOpen
>
(
new
ExtHostQuickOpen
(
threadService
));
const
extHostTerminalService
=
col
.
define
(
ExtHostContext
.
ExtHostTerminalService
).
set
<
ExtHostTerminalService
>
(
new
ExtHostTerminalService
(
threadService
));
const
extHostTerminalService
=
col
.
define
(
ExtHostContext
.
ExtHostTerminalService
).
set
<
ExtHostTerminalService
>
(
new
ExtHostTerminalService
(
threadService
));
const
extHostSCM
=
col
.
define
(
ExtHostContext
.
ExtHostSCM
).
set
<
ExtHostSCM
>
(
new
ExtHostSCM
(
threadService
));
const
extHostSCM
=
col
.
define
(
ExtHostContext
.
ExtHostSCM
).
set
<
ExtHostSCM
>
(
new
ExtHostSCM
(
threadService
,
extHostCommands
));
const
extHostTask
=
col
.
define
(
ExtHostContext
.
ExtHostTask
).
set
<
ExtHostTask
>
(
new
ExtHostTask
(
threadService
));
const
extHostTask
=
col
.
define
(
ExtHostContext
.
ExtHostTask
).
set
<
ExtHostTask
>
(
new
ExtHostTask
(
threadService
));
col
.
define
(
ExtHostContext
.
ExtHostExtensionService
).
set
(
extensionService
);
col
.
define
(
ExtHostContext
.
ExtHostExtensionService
).
set
(
extensionService
);
col
.
finish
(
false
,
threadService
);
col
.
finish
(
false
,
threadService
);
...
@@ -448,30 +448,30 @@ export function createApiFactory(
...
@@ -448,30 +448,30 @@ export function createApiFactory(
class
SCM
{
class
SCM
{
get
active
Provider
()
{
get
active
SourceControl
()
{
return
extHostSCM
.
activeProvider
;
return
extHostSCM
.
activeProvider
;
}
}
get
onDidChangeActive
Provider
()
{
get
onDidChangeActive
SourceControl
()
{
return
extHostSCM
.
onDidChangeActiveProvider
;
return
extHostSCM
.
onDidChangeActiveProvider
;
}
}
get
onDidAcceptInputValue
()
{
return
mapEvent
(
extHostSCM
.
inputBox
.
onDidAccept
,
()
=>
extHostSCM
.
inputBox
);
}
get
inputBox
()
{
get
inputBox
()
{
return
extHostSCM
.
inputBox
;
return
extHostSCM
.
inputBox
;
}
}
registerSCMProvider
(
provider
:
vscode
.
SCMProvider
)
{
get
onDidAcceptInputValue
()
{
return
mapEvent
(
extHostSCM
.
inputBox
.
onDidAccept
,
()
=>
extHostSCM
.
inputBox
);
}
createSourceControl
(
id
:
string
,
label
:
string
)
{
telemetryService
.
publicLog
(
'
registerSCMProvider
'
,
{
telemetryService
.
publicLog
(
'
registerSCMProvider
'
,
{
extensionId
:
extension
.
id
,
extensionId
:
extension
.
id
,
provider
Label
:
provider
.
label
,
provider
Id
:
id
,
provider
ContextKey
:
provider
.
contextKey
provider
Label
:
label
});
});
return
extHostSCM
.
registerSCMProvider
(
provider
);
return
extHostSCM
.
createSourceControl
(
id
,
label
);
}
}
}
}
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
ccfcbe6c
...
@@ -251,30 +251,31 @@ export abstract class MainProcessExtensionServiceShape {
...
@@ -251,30 +251,31 @@ export abstract class MainProcessExtensionServiceShape {
}
}
export
interface
SCMProviderFeatures
{
export
interface
SCMProviderFeatures
{
label
:
string
;
hasQuickDiffProvider
?:
boolean
;
contextKey
?:
string
;
count
?:
number
;
supportsOpen
:
boolean
;
}
supportsOriginalResource
:
boolean
;
export
interface
SCMGroupFeatures
{
hideWhenEmpty
?:
boolean
;
}
}
export
type
SCMRawResource
=
[
export
type
SCMRawResource
=
[
string
/*
u
ri*/
,
string
/*
resourceU
ri*/
,
string
/*sourceUri
*/
,
modes
.
Command
/*command
*/
,
string
[]
/*icons: light, dark*/
,
string
[]
/*icons: light, dark*/
,
boolean
/*strike through*/
boolean
/*strike through*/
];
];
export
type
SCMRawResourceGroup
=
[
string
/*uri*/
,
string
|
undefined
/*context key*/
,
string
/*label*/
,
SCMRawResource
[]
];
export
abstract
class
MainThreadSCMShape
{
export
abstract
class
MainThreadSCMShape
{
$register
(
handle
:
number
,
features
:
SCMProviderFeatures
):
void
{
throw
ni
();
}
$registerSourceControl
(
handle
:
number
,
id
:
string
,
label
:
string
):
void
{
throw
ni
();
}
$unregister
(
handle
:
number
):
void
{
throw
ni
();
}
$updateSourceControl
(
handle
:
number
,
features
:
SCMProviderFeatures
):
void
{
throw
ni
();
}
$onChange
(
handle
:
number
,
resources
:
SCMRawResourceGroup
[],
count
:
number
|
undefined
,
stateContextKey
:
string
|
undefined
):
void
{
throw
ni
();
}
$unregisterSourceControl
(
handle
:
number
):
void
{
throw
ni
();
}
$registerGroup
(
sourceControlHandle
:
number
,
handle
:
number
,
id
:
string
,
label
:
string
):
void
{
throw
ni
();
}
$updateGroup
(
sourceControlHandle
:
number
,
handle
:
number
,
features
:
SCMGroupFeatures
):
void
{
throw
ni
();
}
$updateGroupResourceStates
(
sourceControlHandle
:
number
,
groupHandle
:
number
,
resources
:
SCMRawResource
[]):
void
{
throw
ni
();
}
$unregisterGroup
(
sourceControlHandle
:
number
,
handle
:
number
):
void
{
throw
ni
();
}
$setInputBoxValue
(
value
:
string
):
void
{
throw
ni
();
}
$setInputBoxValue
(
value
:
string
):
void
{
throw
ni
();
}
}
}
...
@@ -418,9 +419,8 @@ export abstract class ExtHostTerminalServiceShape {
...
@@ -418,9 +419,8 @@ export abstract class ExtHostTerminalServiceShape {
}
}
export
abstract
class
ExtHostSCMShape
{
export
abstract
class
ExtHostSCMShape
{
$open
(
handle
:
number
,
uri
:
string
):
TPromise
<
void
>
{
throw
ni
();
}
$provideOriginalResource
(
sourceControlHandle
:
number
,
uri
:
URI
):
TPromise
<
URI
>
{
throw
ni
();
}
$getOriginalResource
(
handle
:
number
,
uri
:
URI
):
TPromise
<
URI
>
{
throw
ni
();
}
$onActiveSourceControlChange
(
sourceControlHandle
:
number
):
TPromise
<
void
>
{
throw
ni
();
}
$onActiveProviderChange
(
handle
:
number
):
TPromise
<
void
>
{
throw
ni
();
}
$onInputBoxValueChange
(
value
:
string
):
TPromise
<
void
>
{
throw
ni
();
}
$onInputBoxValueChange
(
value
:
string
):
TPromise
<
void
>
{
throw
ni
();
}
$onInputBoxAcceptChanges
():
TPromise
<
void
>
{
throw
ni
();
}
$onInputBoxAcceptChanges
():
TPromise
<
void
>
{
throw
ni
();
}
}
}
...
...
src/vs/workbench/api/node/extHostSCM.ts
浏览文件 @
ccfcbe6c
...
@@ -6,14 +6,14 @@
...
@@ -6,14 +6,14 @@
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
Event
,
{
Emitter
,
debounceEvent
,
createEmptyEvent
}
from
'
vs/base/common/event
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
Disposable
}
from
'
vs/workbench/api/node/extHostType
s
'
;
import
{
ExtHostCommands
,
CommandsConverter
}
from
'
vs/workbench/api/node/extHostCommand
s
'
;
import
{
MainContext
,
MainThreadSCMShape
,
SCMRawResource
,
SCMRawResourceGroup
}
from
'
./extHost.protocol
'
;
import
{
MainContext
,
MainThreadSCMShape
,
SCMRawResource
}
from
'
./extHost.protocol
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
vscode
from
'
vscode
'
;
function
getIconPath
(
decorations
:
vscode
.
S
CM
ResourceThemableDecorations
)
{
function
getIconPath
(
decorations
:
vscode
.
S
ourceControl
ResourceThemableDecorations
)
{
if
(
!
decorations
)
{
if
(
!
decorations
)
{
return
undefined
;
return
undefined
;
}
else
if
(
typeof
decorations
.
iconPath
===
'
string
'
)
{
}
else
if
(
typeof
decorations
.
iconPath
===
'
string
'
)
{
...
@@ -67,119 +67,179 @@ export class ExtHostSCMInputBox {
...
@@ -67,119 +67,179 @@ export class ExtHostSCMInputBox {
}
}
}
}
type
ProviderHandle
=
number
;
class
ExtHostSourceControlResourceGroup
implements
vscode
.
SourceControlResourceGroup
{
export
class
ExtHostSCM
{
private
static
_handlePool
:
number
=
0
;
private
static
_handlePool
:
number
=
0
;
private
_proxy
:
MainThreadSCMShape
;
get
id
():
string
{
private
_providers
:
Map
<
ProviderHandle
,
vscode
.
SCMProvider
>
=
new
Map
<
ProviderHandle
,
vscode
.
SCMProvider
>
()
;
return
this
.
_id
;
private
_cache
:
Map
<
ProviderHandle
,
Map
<
string
,
vscode
.
SCMResource
>>
=
new
Map
<
ProviderHandle
,
Map
<
string
,
vscode
.
SCMResource
>>
();
}
private
_onDidChangeActiveProvider
=
new
Emitter
<
vscode
.
SCMProvider
>
();
get
label
():
string
{
get
onDidChangeActiveProvider
():
Event
<
vscode
.
SCMProvider
>
{
return
this
.
_onDidChangeActiveProvider
.
event
;
}
return
this
.
_label
;
}
private
_activeProvider
:
vscode
.
SCMProvider
|
undefined
;
private
_hideWhenEmpty
:
boolean
|
undefined
=
undefined
;
get
activeProvider
():
vscode
.
SCMProvider
|
undefined
{
return
this
.
_activeProvider
;
}
private
_inputBox
:
ExtHostSCMInputBox
;
get
hideWhenEmpty
():
boolean
|
undefined
{
get
inputBox
():
ExtHostSCMInputBox
{
return
this
.
_inputBox
;
}
return
this
.
_hideWhenEmpty
;
}
constructor
(
threadService
:
IThreadService
)
{
set
hideWhenEmpty
(
hideWhenEmpty
:
boolean
|
undefined
)
{
this
.
_
proxy
=
threadService
.
get
(
MainContext
.
MainThreadSCM
)
;
this
.
_
hideWhenEmpty
=
hideWhenEmpty
;
this
.
_
inputBox
=
new
ExtHostSCMInputBox
(
this
.
_proxy
);
this
.
_
proxy
.
$updateGroup
(
this
.
_sourceControlHandle
,
this
.
_handle
,
{
hideWhenEmpty
}
);
}
}
registerSCMProvider
(
provider
:
vscode
.
SCMProvider
):
Disposable
{
private
_resourcesStates
:
vscode
.
SourceControlResourceState
[]
=
[];
const
handle
=
ExtHostSCM
.
_handlePool
++
;
get
resourceStates
():
vscode
.
SourceControlResourceState
[]
{
return
this
.
_resourcesStates
;
}
set
resourceStates
(
resources
:
vscode
.
SourceControlResourceState
[])
{
this
.
_resourcesStates
=
resources
;
const
rawResources
=
resources
.
map
(
r
=>
{
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
[]
=
[];
this
.
_providers
.
set
(
handle
,
provider
);
if
(
lightIconPath
||
darkIconPath
)
{
icons
.
push
(
lightIconPath
);
}
this
.
_proxy
.
$register
(
handle
,
{
if
(
darkIconPath
!==
lightIconPath
)
{
label
:
provider
.
label
,
icons
.
push
(
darkIconPath
);
contextKey
:
provider
.
contextKey
,
}
supportsOpen
:
!!
provider
.
open
,
supportsOriginalResource
:
!!
provider
.
provideOriginalResource
const
strikeThrough
=
r
.
decorations
&&
!!
r
.
decorations
.
strikeThrough
;
return
[
sourceUri
,
command
,
icons
,
strikeThrough
]
as
SCMRawResource
;
});
});
const
onDidChange
=
debounceEvent
(
provider
.
onDidChange
||
createEmptyEvent
<
vscode
.
SCMProvider
>
(),
(
l
,
e
)
=>
e
,
100
);
this
.
_proxy
.
$updateGroupResourceStates
(
this
.
_sourceControlHandle
,
this
.
_handle
,
rawResources
);
const
onDidChangeListener
=
onDidChange
(
scmProvider
=>
{
}
const
cache
=
new
Map
<
string
,
vscode
.
SCMResource
>
();
this
.
_cache
.
set
(
handle
,
cache
);
const
rawResourceGroups
=
scmProvider
.
resources
.
map
(
g
=>
{
private
_handle
:
number
=
ExtHostSourceControlResourceGroup
.
_handlePool
++
;
const
rawResources
=
g
.
resources
.
map
(
r
=>
{
const
uri
=
r
.
uri
.
toString
();
cache
.
set
(
uri
,
r
);
const
sourceUri
=
r
.
sourceUri
.
toString
();
constructor
(
const
iconPath
=
getIconPath
(
r
.
decorations
);
private
_proxy
:
MainThreadSCMShape
,
const
lightIconPath
=
r
.
decorations
&&
getIconPath
(
r
.
decorations
.
light
)
||
iconPath
;
private
_commands
:
CommandsConverter
,
const
darkIconPath
=
r
.
decorations
&&
getIconPath
(
r
.
decorations
.
dark
)
||
iconPath
;
private
_sourceControlHandle
:
number
,
const
icons
:
string
[]
=
[];
private
_id
:
string
,
private
_label
:
string
,
)
{
this
.
_proxy
.
$registerGroup
(
_sourceControlHandle
,
this
.
_handle
,
_id
,
_label
);
}
if
(
lightIconPath
||
darkIconPath
)
{
dispose
():
void
{
icons
.
push
(
lightIconPath
);
this
.
_proxy
.
$unregisterGroup
(
this
.
_sourceControlHandle
,
this
.
_handle
);
}
}
}
if
(
darkIconPath
!==
lightIconPath
)
{
class
ExtHostSourceControl
implements
vscode
.
SourceControl
{
icons
.
push
(
darkIconPath
);
}
const
strikeThrough
=
r
.
decorations
&&
!!
r
.
decorations
.
strikeThrough
;
private
static
_handlePool
:
number
=
0
;
return
[
uri
,
sourceUri
,
icons
,
strikeThrough
]
as
SCMRawResource
;
get
id
():
string
{
});
return
this
.
_id
;
}
return
[
g
.
uri
.
toString
(),
g
.
contextKey
,
g
.
label
,
rawResources
]
as
SCMRawResourceGroup
;
get
label
():
string
{
});
return
this
.
_label
;
}
this
.
_proxy
.
$onChange
(
handle
,
rawResourceGroups
,
provider
.
count
,
provider
.
stateContextKey
);
private
_count
:
number
|
undefined
=
undefined
;
});
return
new
Disposable
(()
=>
{
get
count
():
number
|
undefined
{
onDidChangeListener
.
dispose
();
return
this
.
_count
;
this
.
_providers
.
delete
(
handle
);
this
.
_proxy
.
$unregister
(
handle
);
});
}
}
$open
(
handle
:
number
,
uri
:
string
):
TPromise
<
void
>
{
set
count
(
count
:
number
|
undefined
)
{
const
provider
=
this
.
_providers
.
get
(
handle
);
this
.
_count
=
count
;
this
.
_proxy
.
$updateSourceControl
(
this
.
_handle
,
{
count
});
}
if
(
!
provider
)
{
private
_quickDiffProvider
:
vscode
.
QuickDiffProvider
|
undefined
=
undefined
;
return
TPromise
.
as
(
null
);
}
get
quickDiffProvider
():
vscode
.
QuickDiffProvider
|
undefined
{
return
this
.
_quickDiffProvider
;
}
const
cache
=
this
.
_cache
.
get
(
handle
);
set
quickDiffProvider
(
quickDiffProvider
:
vscode
.
QuickDiffProvider
|
undefined
)
{
this
.
_quickDiffProvider
=
quickDiffProvider
;
this
.
_proxy
.
$updateSourceControl
(
this
.
_handle
,
{
hasQuickDiffProvider
:
!!
quickDiffProvider
});
}
if
(
!
cache
)
{
private
_handle
:
number
=
ExtHostSourceControl
.
_handlePool
++
;
return
TPromise
.
as
(
null
);
}
const
resource
=
cache
.
get
(
uri
);
constructor
(
private
_proxy
:
MainThreadSCMShape
,
private
_commands
:
CommandsConverter
,
private
_id
:
string
,
private
_label
:
string
,
)
{
this
.
_proxy
.
$registerSourceControl
(
this
.
_handle
,
_id
,
_label
);
}
if
(
!
resource
)
{
createResourceGroup
(
id
:
string
,
label
:
string
):
ExtHostSourceControlResourceGroup
{
return
TPromise
.
as
(
nul
l
);
return
new
ExtHostSourceControlResourceGroup
(
this
.
_proxy
,
this
.
_commands
,
this
.
_handle
,
id
,
labe
l
);
}
}
provider
.
open
(
resource
);
dispose
():
void
{
return
TPromise
.
as
(
null
);
this
.
_proxy
.
$unregisterSourceControl
(
this
.
_handle
);
}
}
type
ProviderHandle
=
number
;
export
class
ExtHostSCM
{
private
static
_handlePool
:
number
=
0
;
private
_proxy
:
MainThreadSCMShape
;
private
_sourceControls
:
Map
<
ProviderHandle
,
vscode
.
SourceControl
>
=
new
Map
<
ProviderHandle
,
vscode
.
SourceControl
>
();
private
_onDidChangeActiveProvider
=
new
Emitter
<
vscode
.
SourceControl
>
();
get
onDidChangeActiveProvider
():
Event
<
vscode
.
SourceControl
>
{
return
this
.
_onDidChangeActiveProvider
.
event
;
}
private
_activeProvider
:
vscode
.
SourceControl
|
undefined
;
get
activeProvider
():
vscode
.
SourceControl
|
undefined
{
return
this
.
_activeProvider
;
}
private
_inputBox
:
ExtHostSCMInputBox
;
get
inputBox
():
ExtHostSCMInputBox
{
return
this
.
_inputBox
;
}
constructor
(
threadService
:
IThreadService
,
private
_commands
:
ExtHostCommands
)
{
this
.
_proxy
=
threadService
.
get
(
MainContext
.
MainThreadSCM
);
this
.
_inputBox
=
new
ExtHostSCMInputBox
(
this
.
_proxy
);
}
createSourceControl
(
id
:
string
,
label
:
string
):
vscode
.
SourceControl
{
const
handle
=
ExtHostSCM
.
_handlePool
++
;
const
sourceControl
=
new
ExtHostSourceControl
(
this
.
_proxy
,
this
.
_commands
.
converter
,
id
,
label
);
this
.
_sourceControls
.
set
(
handle
,
sourceControl
);
return
sourceControl
;
}
}
$
getOriginalResource
(
h
andle
:
number
,
uri
:
URI
):
TPromise
<
URI
>
{
$
provideOriginalResource
(
sourceControlH
andle
:
number
,
uri
:
URI
):
TPromise
<
URI
>
{
const
provider
=
this
.
_providers
.
get
(
h
andle
);
const
sourceControl
=
this
.
_sourceControls
.
get
(
sourceControlH
andle
);
if
(
!
p
rovider
)
{
if
(
!
sourceControl
||
!
sourceControl
.
quickDiffP
rovider
)
{
return
TPromise
.
as
(
null
);
return
TPromise
.
as
(
null
);
}
}
return
asWinJsPromise
(
token
=>
p
rovider
.
provideOriginalResource
(
uri
,
token
));
return
asWinJsPromise
(
token
=>
sourceControl
.
quickDiffP
rovider
.
provideOriginalResource
(
uri
,
token
));
}
}
$onActive
Provider
Change
(
handle
:
number
):
TPromise
<
void
>
{
$onActive
SourceControl
Change
(
handle
:
number
):
TPromise
<
void
>
{
this
.
_activeProvider
=
this
.
_
provider
s
.
get
(
handle
);
this
.
_activeProvider
=
this
.
_
sourceControl
s
.
get
(
handle
);
return
TPromise
.
as
(
null
);
return
TPromise
.
as
(
null
);
}
}
...
...
src/vs/workbench/api/node/mainThreadSCM.ts
浏览文件 @
ccfcbe6c
...
@@ -7,154 +7,223 @@
...
@@ -7,154 +7,223 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/error
s
'
;
import
{
assign
}
from
'
vs/base/common/object
s
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
ISCMService
,
ISCMProvider
,
ISCMResource
,
ISCMResourceGroup
}
from
'
vs/workbench/services/scm/common/scm
'
;
import
{
ISCMService
,
ISCMProvider
,
ISCMResource
,
ISCMResourceGroup
}
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
,
SCMRawResourceGroup
}
from
'
./extHost.protocol
'
;
import
{
ExtHostContext
,
MainThreadSCMShape
,
ExtHostSCMShape
,
SCMProviderFeatures
,
SCMRawResource
,
SCMGroupFeatures
}
from
'
./extHost.protocol
'
;
interface
IMainThreadSCMResourceGroup
{
uri
:
URI
;
features
:
SCMGroupFeatures
;
label
:
string
;
contextKey
?:
string
;
resources
:
ISCMResource
[];
}
class
MainThreadSCMProvider
implements
ISCMProvider
{
class
MainThreadSCMProvider
implements
ISCMProvider
{
private
_resources
:
ISCMResourceGroup
[]
=
[];
private
_groups
:
IMainThreadSCMResourceGroup
[]
=
[];
get
resources
():
ISCMResourceGroup
[]
{
return
this
.
_resources
;
}
private
_groupsByHandle
:
{
[
handle
:
number
]:
IMainThreadSCMResourceGroup
;
}
=
Object
.
create
(
null
);
get
resources
():
ISCMResourceGroup
[]
{
return
this
.
_groups
.
filter
(
g
=>
g
.
resources
.
length
>
0
||
!
g
.
features
.
hideWhenEmpty
);
}
private
_onDidChange
=
new
Emitter
<
ISCMResourceGroup
[]
>
();
private
_onDidChange
=
new
Emitter
<
void
>
();
get
onDidChange
():
Event
<
ISCMResourceGroup
[]
>
{
return
this
.
_onDidChange
.
event
;
}
get
onDidChange
():
Event
<
void
>
{
return
this
.
_onDidChange
.
event
;
}
private
disposables
:
IDisposable
[]
=
[]
;
private
features
:
SCMProviderFeatures
=
{}
;
get
handle
():
number
{
return
this
.
_handle
;
}
get
handle
():
number
{
return
this
.
_handle
;
}
get
label
():
string
{
return
this
.
features
.
label
;
}
get
label
():
string
{
return
this
.
_
label
;
}
get
contextKey
():
string
{
return
this
.
features
.
contextKey
;
}
get
contextKey
():
string
{
return
this
.
_id
;
}
private
_count
:
number
|
undefined
=
undefined
;
private
_count
:
number
|
undefined
=
undefined
;
get
count
():
number
|
undefined
{
return
this
.
_count
;
}
get
count
():
number
|
undefined
{
return
this
.
_count
;
}
private
_stateContextKey
:
string
|
undefined
=
undefined
;
get
stateContextKey
():
string
|
undefined
{
return
this
.
_stateContextKey
;
}
constructor
(
constructor
(
private
_handle
:
number
,
private
proxy
:
ExtHostSCMShape
,
private
proxy
:
ExtHostSCMShape
,
private
features
:
SCMProviderFeatures
,
private
_handle
:
number
,
private
_id
:
string
,
private
_label
:
string
,
@
ISCMService
scmService
:
ISCMService
,
@
ISCMService
scmService
:
ISCMService
,
@
ICommandService
private
commandService
:
ICommandService
@
ICommandService
private
commandService
:
ICommandService
)
{
)
{
}
scmService
.
onDidChangeProvider
(
this
.
onDidChangeProvider
,
this
,
this
.
disposables
);
$updateSourceControl
(
features
:
SCMProviderFeatures
):
void
{
this
.
features
=
assign
(
this
.
features
,
features
);
this
.
_onDidChange
.
fire
();
}
$registerGroup
(
handle
:
number
,
id
:
string
,
label
:
string
):
void
{
const
group
:
IMainThreadSCMResourceGroup
=
{
contextKey
:
id
,
label
,
uri
:
null
,
resources
:
[],
features
:
{}
};
this
.
_groups
.
push
(
group
);
this
.
_groupsByHandle
[
handle
]
=
group
;
}
}
open
(
resource
:
ISCMResource
):
void
{
$updateGroup
(
handle
:
number
,
features
:
SCMGroupFeatures
):
void
{
if
(
!
this
.
features
.
supportsOpen
)
{
const
group
=
this
.
_groupsByHandle
[
handle
];
if
(
!
group
)
{
return
;
return
;
}
}
this
.
proxy
.
$open
(
this
.
handle
,
resource
.
uri
.
toString
())
group
.
features
=
assign
(
group
.
features
,
features
);
.
done
(
null
,
onUnexpectedError
);
this
.
_onDidChange
.
fire
(
);
}
}
getOriginalResource
(
uri
:
URI
):
TPromise
<
URI
>
{
$updateGroupResourceStates
(
handle
:
number
,
resources
:
SCMRawResource
[]):
void
{
if
(
!
this
.
features
.
supportsOriginalResource
)
{
const
group
=
this
.
_groupsByHandle
[
handle
];
return
TPromise
.
as
(
null
);
if
(
!
group
)
{
return
;
}
}
return
this
.
proxy
.
$getOriginalResource
(
this
.
handle
,
uri
);
group
.
resources
=
resources
.
map
(
rawResource
=>
{
const
[
sourceUri
,
command
,
icons
,
strikeThrough
]
=
rawResource
;
const
icon
=
icons
[
0
];
const
iconDark
=
icons
[
1
]
||
icon
;
const
decorations
=
{
icon
:
icon
&&
URI
.
parse
(
icon
),
iconDark
:
iconDark
&&
URI
.
parse
(
iconDark
),
strikeThrough
};
return
{
sourceUri
:
URI
.
parse
(
sourceUri
),
command
,
resourceGroup
:
group
,
decorations
};
});
this
.
_onDidChange
.
fire
();
}
}
private
onDidChangeProvider
(
provider
:
ISCMProvider
):
void
{
$unregisterGroup
(
handle
:
number
):
void
{
// if (provider === this) {
const
group
=
this
.
_groupsByHandle
[
handle
];
// return
// }
if
(
!
group
)
{
}
return
;
}
$onChange
(
rawResourceGroups
:
SCMRawResourceGroup
[],
count
:
number
|
undefined
,
stateContextKey
:
string
|
undefined
):
void
{
this
.
_resources
=
rawResourceGroups
.
map
(
rawGroup
=>
{
const
[
uri
,
contextKey
,
label
,
rawResources
]
=
rawGroup
;
const
resources
:
ISCMResource
[]
=
[];
const
group
:
ISCMResourceGroup
=
{
uri
:
URI
.
parse
(
uri
),
contextKey
,
label
,
resources
};
rawResources
.
forEach
(
rawResource
=>
{
const
[
uri
,
sourceUri
,
icons
,
strikeThrough
]
=
rawResource
;
const
icon
=
icons
[
0
];
const
iconDark
=
icons
[
1
]
||
icon
;
const
decorations
=
{
icon
:
icon
&&
URI
.
parse
(
icon
),
iconDark
:
iconDark
&&
URI
.
parse
(
iconDark
),
strikeThrough
};
resources
.
push
({
resourceGroup
:
group
,
uri
:
URI
.
parse
(
uri
),
sourceUri
:
URI
.
parse
(
sourceUri
),
decorations
});
});
return
group
;
});
this
.
_count
=
count
;
delete
this
.
_groupsByHandle
[
handle
];
this
.
_stateContextKey
=
stateContextKey
;
this
.
_groups
.
splice
(
this
.
_groups
.
indexOf
(
group
),
1
);
}
this
.
_onDidChange
.
fire
(
this
.
resources
);
getOriginalResource
(
uri
:
URI
):
TPromise
<
URI
>
{
if
(
!
this
.
features
.
hasQuickDiffProvider
)
{
return
TPromise
.
as
(
null
);
}
return
this
.
proxy
.
$provideOriginalResource
(
this
.
handle
,
uri
);
}
}
dispose
():
void
{
dispose
():
void
{
this
.
disposables
=
dispose
(
this
.
disposables
);
}
}
}
}
export
class
MainThreadSCM
extends
MainThreadSCMShape
{
export
class
MainThreadSCM
extends
MainThreadSCMShape
{
private
proxy
:
ExtHostSCMShape
;
private
_proxy
:
ExtHostSCMShape
;
private
providers
:
{
[
handle
:
number
]:
MainThreadSCMProvider
;
}
=
Object
.
create
(
null
);
private
_sourceControls
:
{
[
handle
:
number
]:
MainThreadSCMProvider
;
}
=
Object
.
create
(
null
);
private
providerDisposables
:
{
[
handle
:
number
]:
IDisposable
;
}
=
Object
.
create
(
null
);
private
_sourceControlDisposables
:
{
[
handle
:
number
]:
IDisposable
;
}
=
Object
.
create
(
null
);
private
_disposables
:
IDisposable
[]
=
[];
private
disposables
:
IDisposable
[]
=
[];
constructor
(
constructor
(
@
IThreadService
threadService
:
IThreadService
,
@
IThreadService
threadService
:
IThreadService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
ISCMService
private
scmService
:
ISCMService
@
ISCMService
private
scmService
:
ISCMService
,
@
ICommandService
private
commandService
:
ICommandService
)
{
)
{
super
();
super
();
this
.
proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostSCM
);
this
.
_proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostSCM
);
this
.
scmService
.
onDidChangeProvider
(
this
.
onDidChangeProvider
,
this
,
this
.
_disposables
);
this
.
scmService
.
input
.
onDidChange
(
this
.
_proxy
.
$onInputBoxValueChange
,
this
.
_proxy
,
this
.
_disposables
);
this
.
scmService
.
input
.
onDidAccept
(
this
.
_proxy
.
$onInputBoxAcceptChanges
,
this
.
_proxy
,
this
.
_disposables
);
}
$registerSourceControl
(
handle
:
number
,
id
:
string
,
label
:
string
):
void
{
const
provider
=
new
MainThreadSCMProvider
(
this
.
_proxy
,
handle
,
id
,
label
,
this
.
scmService
,
this
.
commandService
);
this
.
_sourceControls
[
handle
]
=
provider
;
this
.
_sourceControlDisposables
[
handle
]
=
this
.
scmService
.
registerSCMProvider
(
provider
);
}
$updateSourceControl
(
handle
:
number
,
features
:
SCMProviderFeatures
):
void
{
const
sourceControl
=
this
.
_sourceControls
[
handle
];
if
(
!
sourceControl
)
{
return
;
}
sourceControl
.
$updateSourceControl
(
features
);
}
$unregisterSourceControl
(
handle
:
number
):
void
{
const
sourceControl
=
this
.
_sourceControls
[
handle
];
if
(
!
sourceControl
)
{
return
;
}
this
.
scmService
.
onDidChangeProvider
(
this
.
onDidChangeProvider
,
this
,
this
.
disposables
);
this
.
_sourceControlDisposables
[
handle
].
dispose
();
this
.
scmService
.
input
.
onDidChange
(
this
.
proxy
.
$onInputBoxValueChange
,
this
.
proxy
,
this
.
disposables
);
delete
this
.
_sourceControlDisposables
[
handle
];
this
.
scmService
.
input
.
onDidAccept
(
this
.
proxy
.
$onInputBoxAcceptChanges
,
this
.
proxy
,
this
.
disposables
);
sourceControl
.
dispose
();
delete
this
.
_sourceControls
[
handle
];
}
}
$register
(
handle
:
number
,
features
:
SCMProviderFeatures
):
void
{
$registerGroup
(
sourceControlHandle
:
number
,
groupHandle
:
number
,
id
:
string
,
label
:
string
):
void
{
const
provider
=
this
.
instantiationService
.
createInstance
(
MainThreadSCMProvider
,
handle
,
this
.
proxy
,
features
);
const
provider
=
this
.
_sourceControls
[
sourceControlHandle
];
this
.
providers
[
handle
]
=
provider
;
this
.
providerDisposables
[
handle
]
=
this
.
scmService
.
registerSCMProvider
(
provider
);
if
(
!
provider
)
{
return
;
}
provider
.
$registerGroup
(
groupHandle
,
id
,
label
);
}
}
$u
nregister
(
handle
:
number
):
void
{
$u
pdateGroup
(
sourceControlHandle
:
number
,
groupHandle
:
number
,
features
:
SCMGroupFeatures
):
void
{
const
provider
=
this
.
providers
[
h
andle
];
const
provider
=
this
.
_sourceControls
[
sourceControlH
andle
];
if
(
!
provider
)
{
if
(
!
provider
)
{
return
;
return
;
}
}
this
.
providerDisposables
[
handle
].
dispose
();
provider
.
$updateGroup
(
groupHandle
,
features
);
delete
this
.
providerDisposables
[
handle
];
}
$updateGroupResourceStates
(
sourceControlHandle
:
number
,
groupHandle
:
number
,
resources
:
SCMRawResource
[]):
void
{
const
provider
=
this
.
_sourceControls
[
sourceControlHandle
];
if
(
!
provider
)
{
return
;
}
provider
.
dispose
();
provider
.
$updateGroupResourceStates
(
groupHandle
,
resources
);
delete
this
.
providers
[
handle
];
}
}
$
onChange
(
handle
:
number
,
rawResourceGroups
:
SCMRawResourceGroup
[],
count
:
number
|
undefined
,
state
:
string
|
undefined
):
void
{
$
unregisterGroup
(
sourceControlHandle
:
number
,
handle
:
number
):
void
{
const
provider
=
this
.
providers
[
h
andle
];
const
provider
=
this
.
_sourceControls
[
sourceControlH
andle
];
if
(
!
provider
)
{
if
(
!
provider
)
{
return
;
return
;
}
}
provider
.
$
onChange
(
rawResourceGroups
,
count
,
stat
e
);
provider
.
$
unregisterGroup
(
handl
e
);
}
}
$setInputBoxValue
(
value
:
string
):
void
{
$setInputBoxValue
(
value
:
string
):
void
{
...
@@ -162,15 +231,15 @@ export class MainThreadSCM extends MainThreadSCMShape {
...
@@ -162,15 +231,15 @@ export class MainThreadSCM extends MainThreadSCMShape {
}
}
private
onDidChangeProvider
(
provider
:
ISCMProvider
):
void
{
private
onDidChangeProvider
(
provider
:
ISCMProvider
):
void
{
const
handle
=
Object
.
keys
(
this
.
providers
).
filter
(
handle
=>
this
.
provider
s
[
handle
]
===
provider
)[
0
];
const
handle
=
Object
.
keys
(
this
.
_sourceControls
).
filter
(
handle
=>
this
.
_sourceControl
s
[
handle
]
===
provider
)[
0
];
this
.
proxy
.
$onActiveProvider
Change
(
handle
&&
parseInt
(
handle
));
this
.
_proxy
.
$onActiveSourceControl
Change
(
handle
&&
parseInt
(
handle
));
}
}
dispose
():
void
{
dispose
():
void
{
Object
.
keys
(
this
.
provider
s
)
Object
.
keys
(
this
.
_sourceControl
s
)
.
forEach
(
id
=>
this
.
provider
s
[
id
].
dispose
());
.
forEach
(
id
=>
this
.
_sourceControl
s
[
id
].
dispose
());
this
.
provider
s
=
Object
.
create
(
null
);
this
.
_sourceControl
s
=
Object
.
create
(
null
);
this
.
disposables
=
dispose
(
this
.
disposables
);
this
.
_disposables
=
dispose
(
this
.
_
disposables
);
}
}
}
}
src/vs/workbench/parts/git/browser/gitScm.ts
浏览文件 @
ccfcbe6c
...
@@ -25,8 +25,8 @@ export class GitSCMProvider implements IWorkbenchContribution, ISCMProvider, ITe
...
@@ -25,8 +25,8 @@ export class GitSCMProvider implements IWorkbenchContribution, ISCMProvider, ITe
get
label
()
{
return
'
Git
'
;
}
get
label
()
{
return
'
Git
'
;
}
get
resources
()
{
return
[];
}
get
resources
()
{
return
[];
}
private
_onDidChange
=
new
Emitter
<
ISCMResourceGroup
[]
>
();
private
_onDidChange
=
new
Emitter
<
void
>
();
get
onDidChange
():
Event
<
ISCMResourceGroup
[]
>
{
get
onDidChange
():
Event
<
void
>
{
return
this
.
_onDidChange
.
event
;
return
this
.
_onDidChange
.
event
;
}
}
...
...
src/vs/workbench/parts/scm/electron-browser/scmViewlet.ts
浏览文件 @
ccfcbe6c
...
@@ -9,6 +9,7 @@ import 'vs/css!./media/scmViewlet';
...
@@ -9,6 +9,7 @@ import 'vs/css!./media/scmViewlet';
import
{
localize
}
from
'
vs/nls
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
chain
}
from
'
vs/base/common/event
'
;
import
{
chain
}
from
'
vs/base/common/event
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
*
as
platform
from
'
vs/base/common/platform
'
;
import
{
domEvent
}
from
'
vs/base/browser/event
'
;
import
{
domEvent
}
from
'
vs/base/browser/event
'
;
import
{
IDisposable
,
dispose
,
empty
as
EmptyDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
,
empty
as
EmptyDisposable
}
from
'
vs/base/common/lifecycle
'
;
...
@@ -27,6 +28,7 @@ import { ISCMService, ISCMProvider, ISCMResourceGroup, ISCMResource } from 'vs/w
...
@@ -27,6 +28,7 @@ import { ISCMService, ISCMProvider, ISCMResourceGroup, ISCMResource } from 'vs/w
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IContextViewService
,
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IContextViewService
,
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ICommandService
}
from
'
vs/platform/commands/common/commands
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
IListService
}
from
'
vs/platform/list/browser/listService
'
;
import
{
IListService
}
from
'
vs/platform/list/browser/listService
'
;
...
@@ -203,7 +205,8 @@ export class SCMViewlet extends Viewlet {
...
@@ -203,7 +205,8 @@ export class SCMViewlet extends Viewlet {
@
IContextMenuService
private
contextMenuService
:
IContextMenuService
,
@
IContextMenuService
private
contextMenuService
:
IContextMenuService
,
@
IThemeService
protected
themeService
:
IThemeService
,
@
IThemeService
protected
themeService
:
IThemeService
,
@
IMenuService
private
menuService
:
IMenuService
,
@
IMenuService
private
menuService
:
IMenuService
,
@
IModelService
private
modelService
:
IModelService
@
IModelService
private
modelService
:
IModelService
,
@
ICommandService
private
commandService
:
ICommandService
)
{
)
{
super
(
VIEWLET_ID
,
telemetryService
,
themeService
);
super
(
VIEWLET_ID
,
telemetryService
,
themeService
);
...
@@ -321,7 +324,8 @@ export class SCMViewlet extends Viewlet {
...
@@ -321,7 +324,8 @@ export class SCMViewlet extends Viewlet {
}
}
private
open
(
e
:
ISCMResource
):
void
{
private
open
(
e
:
ISCMResource
):
void
{
this
.
scmService
.
activeProvider
.
open
(
e
);
this
.
commandService
.
executeCommand
(
e
.
command
.
id
,
...
e
.
command
.
arguments
)
.
done
(
undefined
,
onUnexpectedError
);
}
}
getActions
():
IAction
[]
{
getActions
():
IAction
[]
{
...
...
src/vs/workbench/services/scm/common/scm.ts
浏览文件 @
ccfcbe6c
...
@@ -10,6 +10,7 @@ import URI from 'vs/base/common/uri';
...
@@ -10,6 +10,7 @@ import URI from 'vs/base/common/uri';
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
Event
from
'
vs/base/common/event
'
;
import
Event
from
'
vs/base/common/event
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Command
}
from
'
vs/editor/common/modes
'
;
export
interface
IBaselineResourceProvider
{
export
interface
IBaselineResourceProvider
{
getBaselineResource
(
resource
:
URI
):
TPromise
<
URI
>
;
getBaselineResource
(
resource
:
URI
):
TPromise
<
URI
>
;
...
@@ -24,14 +25,15 @@ export interface ISCMResourceDecorations {
...
@@ -24,14 +25,15 @@ export interface ISCMResourceDecorations {
}
}
export
interface
ISCMResource
{
export
interface
ISCMResource
{
// readonly uri: URI;
readonly
resourceGroup
:
ISCMResourceGroup
;
readonly
resourceGroup
:
ISCMResourceGroup
;
readonly
uri
:
URI
;
readonly
sourceUri
:
URI
;
readonly
sourceUri
:
URI
;
readonly
command
:
Command
;
readonly
decorations
:
ISCMResourceDecorations
;
readonly
decorations
:
ISCMResourceDecorations
;
}
}
export
interface
ISCMResourceGroup
{
export
interface
ISCMResourceGroup
{
readonly
uri
:
URI
;
//
readonly uri: URI;
readonly
label
:
string
;
readonly
label
:
string
;
readonly
contextKey
?:
string
;
readonly
contextKey
?:
string
;
readonly
resources
:
ISCMResource
[];
readonly
resources
:
ISCMResource
[];
...
@@ -41,11 +43,10 @@ export interface ISCMProvider extends IDisposable {
...
@@ -41,11 +43,10 @@ export interface ISCMProvider extends IDisposable {
readonly
label
:
string
;
readonly
label
:
string
;
readonly
contextKey
?:
string
;
readonly
contextKey
?:
string
;
readonly
resources
:
ISCMResourceGroup
[];
readonly
resources
:
ISCMResourceGroup
[];
readonly
onDidChange
:
Event
<
ISCMResourceGroup
[]
>
;
// TODO: Event<void>
readonly
onDidChange
:
Event
<
void
>
;
readonly
count
?:
number
;
readonly
count
?:
number
;
readonly
stateContextKey
?:
string
;
open
(
uri
:
ISCMResource
):
void
;
getOriginalResource
(
uri
:
URI
):
TPromise
<
URI
>
;
getOriginalResource
(
uri
:
URI
):
TPromise
<
URI
>
;
}
}
...
...
src/vs/workbench/services/scm/common/scmService.ts
浏览文件 @
ccfcbe6c
...
@@ -41,7 +41,6 @@ export class SCMService implements ISCMService {
...
@@ -41,7 +41,6 @@ export class SCMService implements ISCMService {
private
providerChangeDisposable
:
IDisposable
=
EmptyDisposable
;
private
providerChangeDisposable
:
IDisposable
=
EmptyDisposable
;
private
activeProviderContextKey
:
IContextKey
<
string
|
undefined
>
;
private
activeProviderContextKey
:
IContextKey
<
string
|
undefined
>
;
private
activeProviderStateContextKey
:
IContextKey
<
string
|
undefined
>
;
private
_activeProvider
:
ISCMProvider
|
undefined
;
private
_activeProvider
:
ISCMProvider
|
undefined
;
...
@@ -62,8 +61,6 @@ export class SCMService implements ISCMService {
...
@@ -62,8 +61,6 @@ export class SCMService implements ISCMService {
this
.
activeProviderContextKey
.
set
(
provider
?
provider
.
contextKey
:
void
0
);
this
.
activeProviderContextKey
.
set
(
provider
?
provider
.
contextKey
:
void
0
);
this
.
providerChangeDisposable
.
dispose
();
this
.
providerChangeDisposable
.
dispose
();
this
.
providerChangeDisposable
=
provider
.
onDidChange
(
this
.
onDidChangeProviderState
,
this
);
this
.
onDidChangeProviderState
();
this
.
_onDidChangeProvider
.
fire
(
provider
);
this
.
_onDidChangeProvider
.
fire
(
provider
);
}
}
...
@@ -81,7 +78,6 @@ export class SCMService implements ISCMService {
...
@@ -81,7 +78,6 @@ export class SCMService implements ISCMService {
@
IContextKeyService
contextKeyService
:
IContextKeyService
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
)
{
this
.
activeProviderContextKey
=
contextKeyService
.
createKey
<
string
|
undefined
>
(
'
scmProvider
'
,
void
0
);
this
.
activeProviderContextKey
=
contextKeyService
.
createKey
<
string
|
undefined
>
(
'
scmProvider
'
,
void
0
);
this
.
activeProviderStateContextKey
=
contextKeyService
.
createKey
<
string
|
undefined
>
(
'
scmProviderState
'
,
void
0
);
}
}
registerSCMProvider
(
provider
:
ISCMProvider
):
IDisposable
{
registerSCMProvider
(
provider
:
ISCMProvider
):
IDisposable
{
...
@@ -105,8 +101,4 @@ export class SCMService implements ISCMService {
...
@@ -105,8 +101,4 @@ export class SCMService implements ISCMService {
}
}
});
});
}
}
private
onDidChangeProviderState
():
void
{
this
.
activeProviderStateContextKey
.
set
(
this
.
activeProvider
.
stateContextKey
);
}
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录