Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
4c302f92
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,发现更多精彩内容 >>
提交
4c302f92
编写于
11月 22, 2016
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
scm api: getOriginalResource
上级
16f4dc86
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
98 addition
and
37 deletion
+98
-37
extensions/git/src/main.ts
extensions/git/src/main.ts
+4
-1
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-1
src/vs/workbench/api/node/extHost.protocol.ts
src/vs/workbench/api/node/extHost.protocol.ts
+4
-1
src/vs/workbench/api/node/extHostSCM.ts
src/vs/workbench/api/node/extHostSCM.ts
+34
-10
src/vs/workbench/api/node/mainThreadSCM.ts
src/vs/workbench/api/node/mainThreadSCM.ts
+36
-6
src/vs/workbench/parts/git/electron-browser/git.contribution.ts
.../workbench/parts/git/electron-browser/git.contribution.ts
+0
-5
src/vs/workbench/parts/scm/browser/dirtydiffDecorator.ts
src/vs/workbench/parts/scm/browser/dirtydiffDecorator.ts
+19
-13
未找到文件。
extensions/git/src/main.ts
浏览文件 @
4c302f92
...
...
@@ -6,6 +6,7 @@
'
use strict
'
;
import
{
scm
,
ExtensionContext
,
workspace
}
from
'
vscode
'
;
import
*
as
path
from
'
path
'
;
import
{
findGit
,
Git
}
from
'
./git
'
;
export
function
log
(...
args
:
any
[]):
void
{
...
...
@@ -36,7 +37,9 @@ export function activate(context: ExtensionContext): any {
const
contentProvider
=
workspace
.
registerTextDocumentContentProvider
(
'
git-index
'
,
{
provideTextDocumentContent
:
uri
=>
{
return
git
.
exec
(
workspace
.
rootPath
,
[
'
show
'
,
uri
.
fsPath
]).
then
(
result
=>
{
const
relativePath
=
path
.
relative
(
workspace
.
rootPath
,
uri
.
fsPath
);
return
git
.
exec
(
workspace
.
rootPath
,
[
'
show
'
,
`HEAD:
${
relativePath
}
`
]).
then
(
result
=>
{
if
(
result
.
exitCode
!==
0
)
{
return
null
;
}
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
4c302f92
...
...
@@ -94,7 +94,7 @@ declare module 'vscode' {
commitCommand
?:
string
;
clickCommand
?:
string
;
dragCommand
?:
string
;
getOriginalResource
?(
uri
:
Uri
):
Uri
|
Thenable
<
Uri
>
;
getOriginalResource
?(
uri
:
Uri
,
token
:
CancellationToken
):
Uri
|
Thenable
<
Uri
>
;
}
export
interface
SCMProvider
extends
Disposable
{
...
...
src/vs/workbench/api/node/extHost.protocol.ts
浏览文件 @
4c302f92
...
...
@@ -229,6 +229,8 @@ export abstract class MainProcessExtensionServiceShape {
}
export
abstract
class
MainThreadSCMShape
{
$register
(
id
:
string
,
registerOriginalResourceProvider
:
boolean
):
void
{
throw
ni
();
}
$unregister
(
id
:
string
):
void
{
throw
ni
();
}
}
// -- extension host
...
...
@@ -359,6 +361,7 @@ export abstract class ExtHostTerminalServiceShape {
}
export
abstract
class
ExtHostSCMShape
{
$getBaselineResource
(
id
:
string
,
uri
:
URI
):
TPromise
<
URI
>
{
throw
ni
();
}
}
// --- proxy identifiers
...
...
@@ -382,7 +385,7 @@ export const MainContext = {
MainThreadTerminalService
:
createMainId
<
MainThreadTerminalServiceShape
>
(
'
MainThreadTerminalService
'
,
MainThreadTerminalServiceShape
),
MainThreadWorkspace
:
createMainId
<
MainThreadWorkspaceShape
>
(
'
MainThreadWorkspace
'
,
MainThreadWorkspaceShape
),
MainProcessExtensionService
:
createMainId
<
MainProcessExtensionServiceShape
>
(
'
MainProcessExtensionService
'
,
MainProcessExtensionServiceShape
),
MainThreadSCM
:
createMainId
(
'
MainThreadSCM
'
,
MainThreadSCMShape
)
MainThreadSCM
:
createMainId
<
MainThreadSCMShape
>
(
'
MainThreadSCM
'
,
MainThreadSCMShape
)
};
export
const
ExtHostContext
=
{
...
...
src/vs/workbench/api/node/extHostSCM.ts
浏览文件 @
4c302f92
...
...
@@ -4,31 +4,45 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
asWinJsPromise
}
from
'
vs/base/common/async
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
SCMProvider
,
SCMDelegate
,
SCMResourceGroup
}
from
'
vscode
'
;
import
{
MainContext
,
MainThreadSCMShape
}
from
'
./extHost.protocol
'
;
export
class
ExtHostSCMProvider
implements
SCMProvider
{
class
ExtHostSCMProvider
implements
SCMProvider
{
private
static
ID_GEN
=
0
;
private
_id
:
number
=
ExtHostSCMProvider
.
ID_GEN
++
;
static
Providers
:
{
[
id
:
string
]:
ExtHostSCMProvider
;
}
=
Object
.
create
(
null
);
constructor
(
private
_proxy
:
MainThreadSCMShape
,
private
_id
:
string
,
private
_delegate
:
SCMDelegate
)
{
}
)
{
if
(
ExtHostSCMProvider
.
Providers
[
_id
])
{
throw
new
Error
(
'
provider already exists
'
);
}
get
id
():
number
{
ExtHostSCMProvider
.
Providers
[
_id
]
=
this
;
_proxy
.
$register
(
this
.
_id
,
!!
this
.
_delegate
.
getOriginalResource
);
}
get
id
():
string
{
return
this
.
_id
;
}
createResourceGroup
(
id
:
string
,
label
:
string
):
SCMResourceGroup
{
// throw new Error('JOAO not implemented');
return
null
;
throw
new
Error
(
'
JOAO not implemented
'
);
}
getBaselineResource
(
uri
:
URI
):
TPromise
<
URI
>
{
return
asWinJsPromise
(
token
=>
this
.
_delegate
.
getOriginalResource
(
uri
,
token
));
}
dispose
():
void
{
// todo
this
.
_proxy
.
$unregister
(
this
.
_id
);
delete
ExtHostSCMProvider
.
Providers
[
this
.
id
];
}
}
...
...
@@ -40,7 +54,17 @@ export class ExtHostSCM {
this
.
_proxy
=
threadService
.
get
(
MainContext
.
MainThreadSCM
);
}
createSCMProvider
(
id
:
string
,
delegate
:
SCMDelegate
):
ExtHostSCMProvider
{
return
new
ExtHostSCMProvider
(
this
.
_proxy
,
delegate
);
createSCMProvider
(
id
:
string
,
delegate
:
SCMDelegate
):
SCMProvider
{
return
new
ExtHostSCMProvider
(
this
.
_proxy
,
id
,
delegate
);
}
$getBaselineResource
(
id
:
string
,
uri
:
URI
):
TPromise
<
URI
>
{
const
provider
=
ExtHostSCMProvider
.
Providers
[
id
];
if
(
!
provider
)
{
return
TPromise
.
as
(
null
);
}
return
provider
.
getBaselineResource
(
uri
);
}
}
src/vs/workbench/api/node/mainThreadSCM.ts
浏览文件 @
4c302f92
...
...
@@ -4,22 +4,52 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
,
combinedDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
MainThreadSCMShape
}
from
'
./extHost.protocol
'
;
import
{
ISCMService
}
from
'
vs/workbench/services/scm/common/scm
'
;
import
{
ExtHostContext
,
MainThreadSCMShape
,
ExtHostSCMShape
}
from
'
./extHost.protocol
'
;
export
class
MainThreadSCM
extends
MainThreadSCMShape
{
private
_toDispose
:
IDisposable
;
private
toDispose
:
IDisposable
;
private
proxy
:
ExtHostSCMShape
;
private
providers
:
{
[
id
:
string
]:
IDisposable
;
}
=
Object
.
create
(
null
);
constructor
(
@
IThreadService
threadService
:
IThreadService
@
IThreadService
threadService
:
IThreadService
,
@
ISCMService
private
scmService
:
ISCMService
)
{
super
();
// const proxy = threadService.get(ExtHostContext.ExtHostSCM);
this
.
proxy
=
threadService
.
get
(
ExtHostContext
.
ExtHostSCM
);
}
$register
(
id
:
string
,
registerOriginalResourceProvider
:
boolean
):
void
{
const
disposables
=
[];
if
(
registerOriginalResourceProvider
)
{
const
baselineProvider
=
this
.
scmService
.
registerBaselineResourceProvider
({
getBaselineResource
:
uri
=>
this
.
proxy
.
$getBaselineResource
(
id
,
uri
)
});
disposables
.
push
(
baselineProvider
);
}
this
.
providers
[
id
]
=
combinedDisposable
(
disposables
);
}
$unregister
(
id
:
string
):
void
{
const
provider
=
this
.
providers
[
id
];
if
(
!
provider
)
{
return
;
}
provider
.
dispose
();
delete
this
.
providers
[
id
];
}
dispose
():
void
{
this
.
_toDispose
=
dispose
(
this
.
_
toDispose
);
this
.
toDispose
=
dispose
(
this
.
toDispose
);
}
}
src/vs/workbench/parts/git/electron-browser/git.contribution.ts
浏览文件 @
4c302f92
...
...
@@ -11,9 +11,7 @@ import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import
{
SyncActionDescriptor
}
from
'
vs/platform/actions/common/actions
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
CloneAction
}
from
'
./gitActions
'
;
import
{
GitContentProvider
}
from
'
../common/gitContentProvider
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
as
WorkbenchActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
registerContributions
();
...
...
@@ -24,6 +22,3 @@ const category = localize('git', "Git");
Registry
.
as
<
IWorkbenchActionRegistry
>
(
WorkbenchActionExtensions
.
WorkbenchActions
)
.
registerWorkbenchAction
(
new
SyncActionDescriptor
(
CloneAction
,
CloneAction
.
ID
,
CloneAction
.
LABEL
),
'
Git: Clone
'
,
category
);
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
)
.
registerWorkbenchContribution
(
GitContentProvider
);
\ No newline at end of file
src/vs/workbench/parts/scm/browser/dirtydiffDecorator.ts
浏览文件 @
4c302f92
...
...
@@ -59,7 +59,7 @@ class DirtyDiffModelDecorator {
private
decorations
:
string
[];
private
baselineModel
:
common
.
IModel
;
private
diffDelayer
:
ThrottledDelayer
<
void
>
;
private
diffDelayer
:
ThrottledDelayer
<
common
.
IChange
[]
>
;
private
toDispose
:
IDisposable
[];
constructor
(
...
...
@@ -73,7 +73,7 @@ class DirtyDiffModelDecorator {
@
ITextModelResolverService
private
textModelResolverService
:
ITextModelResolverService
)
{
this
.
decorations
=
[];
this
.
diffDelayer
=
new
ThrottledDelayer
<
void
>
(
200
);
this
.
diffDelayer
=
new
ThrottledDelayer
<
common
.
IChange
[]
>
(
200
);
this
.
toDispose
=
[];
this
.
triggerDiff
();
this
.
toDispose
.
push
(
model
.
onDidChangeContent
(()
=>
this
.
triggerDiff
()));
...
...
@@ -82,18 +82,24 @@ class DirtyDiffModelDecorator {
@
memoize
private
get
originalURIPromise
():
winjs
.
TPromise
<
URI
>
{
return
this
.
scmService
.
getBaselineResource
(
this
.
uri
)
.
then
(
originalUri
=>
this
.
textModelResolverService
.
createModelReference
(
originalUri
)
.
then
(
ref
=>
{
this
.
baselineModel
=
ref
.
object
.
textEditorModel
;
.
then
(
originalUri
=>
{
if
(
!
originalUri
)
{
return
null
;
}
return
this
.
textModelResolverService
.
createModelReference
(
originalUri
)
.
then
(
ref
=>
{
this
.
baselineModel
=
ref
.
object
.
textEditorModel
;
this
.
toDispose
.
push
(
ref
);
this
.
toDispose
.
push
(
ref
.
object
.
textEditorModel
.
onDidChangeContent
(()
=>
this
.
triggerDiff
()));
this
.
toDispose
.
push
(
ref
);
this
.
toDispose
.
push
(
ref
.
object
.
textEditorModel
.
onDidChangeContent
(()
=>
this
.
triggerDiff
()));
return
originalUri
;
}));
return
originalUri
;
});
});
}
private
triggerDiff
():
winjs
.
Promise
{
private
triggerDiff
():
winjs
.
TPromise
<
void
>
{
if
(
!
this
.
diffDelayer
)
{
return
winjs
.
TPromise
.
as
(
null
);
}
...
...
@@ -113,13 +119,13 @@ class DirtyDiffModelDecorator {
});
}
private
diff
():
winjs
.
Promise
{
private
diff
():
winjs
.
TPromise
<
common
.
IChange
[]
>
{
return
this
.
originalURIPromise
.
then
(
originalURI
=>
{
if
(
!
this
.
model
||
this
.
model
.
isDisposed
())
{
if
(
!
this
.
model
||
this
.
model
.
isDisposed
()
||
!
originalURI
)
{
return
winjs
.
TPromise
.
as
<
any
>
([]);
// disposed
}
this
.
editorWorkerService
.
computeDirtyDiff
(
originalURI
,
this
.
model
.
uri
,
true
);
return
this
.
editorWorkerService
.
computeDirtyDiff
(
originalURI
,
this
.
model
.
uri
,
true
);
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录