Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e06a8382
V
vscode
项目概览
xxadev
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
e06a8382
编写于
3月 27, 2017
作者:
J
Joao Moreno
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
🎨
fix scm api based on @jrieken's recommendations
上级
b0557082
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
47 addition
and
40 deletion
+47
-40
extensions/git/src/main.ts
extensions/git/src/main.ts
+7
-2
extensions/git/src/scmProvider.ts
extensions/git/src/scmProvider.ts
+6
-6
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+13
-19
src/vs/workbench/api/node/extHost.api.impl.ts
src/vs/workbench/api/node/extHost.api.impl.ts
+6
-1
src/vs/workbench/api/node/extHostSCM.ts
src/vs/workbench/api/node/extHostSCM.ts
+9
-8
src/vs/workbench/api/node/mainThreadSCM.ts
src/vs/workbench/api/node/mainThreadSCM.ts
+5
-3
src/vs/workbench/services/scm/common/scm.ts
src/vs/workbench/services/scm/common/scm.ts
+1
-1
未找到文件。
extensions/git/src/main.ts
浏览文件 @
e06a8382
...
...
@@ -15,6 +15,7 @@ import { GitContentProvider } from './contentProvider';
import
{
AutoFetcher
}
from
'
./autofetch
'
;
import
{
MergeDecorator
}
from
'
./merge
'
;
import
{
Askpass
}
from
'
./askpass
'
;
import
{
filterEvent
}
from
'
./util
'
;
import
TelemetryReporter
from
'
vscode-extension-telemetry
'
;
import
*
as
nls
from
'
vscode-nls
'
;
...
...
@@ -76,8 +77,12 @@ async function init(context: ExtensionContext, disposables: Disposable[]): Promi
}
}
scm
.
inputBox
.
onDidAccept
(
commandCenter
.
commitWithInput
,
commandCenter
,
disposables
);
scm
.
inputBox
.
value
=
await
model
.
getCommitTemplate
();
filterEvent
(
scm
.
onDidAcceptInputValue
,
()
=>
scm
.
activeProvider
===
provider
)
(
commandCenter
.
commitWithInput
,
commandCenter
,
disposables
);
if
(
scm
.
activeProvider
===
provider
)
{
scm
.
inputBox
.
value
=
await
model
.
getCommitTemplate
();
}
}
export
function
activate
(
context
:
ExtensionContext
):
any
{
...
...
extensions/git/src/scmProvider.ts
浏览文件 @
e06a8382
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
scm
,
Uri
,
Disposable
,
SCMProvider
,
SCMResourceGroup
,
Event
,
ProviderResult
,
workspace
}
from
'
vscode
'
;
import
{
scm
,
Uri
,
Disposable
,
SCMProvider
,
SCMResourceGroup
,
Event
,
workspace
}
from
'
vscode
'
;
import
{
Model
,
Resource
,
State
}
from
'
./model
'
;
import
{
CommandCenter
}
from
'
./commands
'
;
import
{
mapEvent
}
from
'
./util
'
;
...
...
@@ -17,8 +17,8 @@ export class GitSCMProvider implements SCMProvider {
get
contextKey
():
string
{
return
'
git
'
;
}
get
resources
():
SCMResourceGroup
[]
{
return
this
.
model
.
resources
;
}
get
onDidChange
():
Event
<
SCMResourceGroup
[]
>
{
return
mapEvent
(
this
.
model
.
onDidChange
,
()
=>
this
.
model
.
resources
);
get
onDidChange
():
Event
<
this
>
{
return
mapEvent
(
this
.
model
.
onDidChange
,
()
=>
this
);
}
get
label
():
string
{
return
'
Git
'
;
}
...
...
@@ -46,11 +46,11 @@ export class GitSCMProvider implements SCMProvider {
scm
.
registerSCMProvider
(
this
);
}
open
(
resource
:
Resource
):
ProviderResult
<
void
>
{
return
this
.
commandCenter
.
open
(
resource
);
open
(
resource
:
Resource
):
void
{
this
.
commandCenter
.
open
(
resource
);
}
get
OriginalResource
(
uri
:
Uri
):
Uri
|
undefined
{
provide
OriginalResource
(
uri
:
Uri
):
Uri
|
undefined
{
if
(
uri
.
scheme
!==
'
file
'
)
{
return
;
}
...
...
src/vs/vscode.proposed.d.ts
浏览文件 @
e06a8382
...
...
@@ -674,8 +674,8 @@ declare module 'vscode' {
}
/**
* An SCM provider is able to provide [SCM resources](#SCMResource) to
Code
,
* notify of changes in them and interact with
Code
in several SCM related ways.
* An SCM provider is able to provide [SCM resources](#SCMResource) to
the editor
,
* notify of changes in them and interact with
the editor
in several SCM related ways.
*/
export
interface
SCMProvider
{
...
...
@@ -713,7 +713,7 @@ declare module 'vscode' {
* - [count](#SCMProvider.count)
* - [state](#SCMProvider.state)
*/
readonly
onDidChange
?:
Event
<
SCM
ResourceGroup
[]
>
;
readonly
onDidChange
?:
Event
<
SCM
Provider
>
;
/**
* Provide a [uri](#Uri) to the original resource of any given resource uri.
...
...
@@ -722,7 +722,7 @@ declare module 'vscode' {
* @param token A cancellation token.
* @return A thenable that resolves to uri of the matching original resource.
*/
get
OriginalResource
?(
uri
:
Uri
,
token
:
CancellationToken
):
ProviderResult
<
Uri
>
;
provide
OriginalResource
?(
uri
:
Uri
,
token
:
CancellationToken
):
ProviderResult
<
Uri
>
;
/**
* Open a specific [SCM resource](#SCMResource). Called when SCM resources
...
...
@@ -732,7 +732,7 @@ declare module 'vscode' {
* @param token A cancellation token.
* @return A thenable which resolves when the resource is open.
*/
open
?(
resource
:
SCMResource
,
token
:
CancellationToken
):
ProviderResult
<
void
>
;
open
?(
resource
:
SCMResource
):
void
;
}
/**
...
...
@@ -744,19 +744,14 @@ declare module 'vscode' {
* Setter and getter for the contents of the input box.
*/
value
:
string
;
}
/**
* An [event](#Event) which fires when the input box value has changed.
*/
readonly
onDidChange
:
Event
<
string
>
;
export
namespace
scm
{
/**
*
An [event](#Event) which fires when the user has accepted the changes
.
*
The currently active [SCM provider](#SCMProvider)
.
*/
readonly
onDidAccept
:
Event
<
string
>
;
}
export
namespace
scm
{
export
let
activeProvider
:
SCMProvider
|
undefined
;
/**
* An [event](#Event) which fires when the active [SCM provider](#SCMProvider)
...
...
@@ -765,19 +760,18 @@ declare module 'vscode' {
export
const
onDidChangeActiveProvider
:
Event
<
SCMProvider
>
;
/**
* The
currently active [SCM provider](#SCMProvider)
.
* The
[input box](#SCMInputBox) in the SCM view
.
*/
export
let
activeProvider
:
SCMProvider
|
undefined
;
export
const
inputBox
:
SCMInputBox
;
/**
*
The [input box](#SCMInputBox) in the SCM view
.
*
An [event](#Event) which fires when the user has accepted the changes
.
*/
export
const
inputBox
:
SCMInputBox
;
export
const
onDidAcceptInputValue
:
Event
<
SCMInputBox
>
;
/**
* Registers an [SCM provider](#SCMProvider).
*
* @param id The provider's id.
* @return A disposable which unregisters the provider.
*/
export
function
registerSCMProvider
(
provider
:
SCMProvider
):
Disposable
;
...
...
src/vs/workbench/api/node/extHost.api.impl.ts
浏览文件 @
e06a8382
...
...
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/
'
use strict
'
;
import
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Emitter
,
mapEvent
}
from
'
vs/base/common/event
'
;
import
{
TrieMap
}
from
'
vs/base/common/map
'
;
import
{
score
}
from
'
vs/editor/common/modes/languageSelector
'
;
import
*
as
Platform
from
'
vs/base/common/platform
'
;
...
...
@@ -451,6 +451,11 @@ export function createApiFactory(initData: IInitData, threadService: IThreadServ
return
extHostSCM
.
onDidChangeActiveProvider
;
}
@
proposed
(
extension
)
get
onDidAcceptInputValue
()
{
return
mapEvent
(
extHostSCM
.
inputBox
.
onDidAccept
,
()
=>
extHostSCM
.
inputBox
);
}
@
proposed
(
extension
)
get
inputBox
()
{
return
extHostSCM
.
inputBox
;
...
...
src/vs/workbench/api/node/extHostSCM.ts
浏览文件 @
e06a8382
...
...
@@ -24,7 +24,7 @@ function getIconPath(decorations: vscode.SCMResourceThemableDecorations) {
return
undefined
;
}
class
ExtHostSCMInputBox
{
export
class
ExtHostSCMInputBox
{
private
_value
:
string
=
''
;
...
...
@@ -84,7 +84,7 @@ export class ExtHostSCM {
get
activeProvider
():
vscode
.
SCMProvider
|
undefined
{
return
this
.
_activeProvider
;
}
private
_inputBox
:
ExtHostSCMInputBox
;
get
inputBox
():
vscode
.
SCMInputBox
{
return
this
.
_inputBox
;
}
get
inputBox
():
ExtHost
SCMInputBox
{
return
this
.
_inputBox
;
}
constructor
(
threadService
:
IThreadService
)
{
this
.
_proxy
=
threadService
.
get
(
MainContext
.
MainThreadSCM
);
...
...
@@ -100,15 +100,15 @@ export class ExtHostSCM {
label
:
provider
.
label
,
contextKey
:
provider
.
contextKey
,
supportsOpen
:
!!
provider
.
open
,
supportsOriginalResource
:
!!
provider
.
get
OriginalResource
supportsOriginalResource
:
!!
provider
.
provide
OriginalResource
});
const
onDidChange
=
debounceEvent
(
provider
.
onDidChange
||
createEmptyEvent
(),
(
l
,
e
)
=>
e
,
100
);
const
onDidChangeListener
=
onDidChange
(
resourceGroups
=>
{
const
onDidChange
=
debounceEvent
(
provider
.
onDidChange
||
createEmptyEvent
<
vscode
.
SCMProvider
>
(),
(
l
,
e
)
=>
e
,
100
);
const
onDidChangeListener
=
onDidChange
(
scmProvider
=>
{
const
cache
=
new
Map
<
string
,
vscode
.
SCMResource
>
();
this
.
_cache
.
set
(
handle
,
cache
);
const
rawResourceGroups
=
resourceGroup
s
.
map
(
g
=>
{
const
rawResourceGroups
=
scmProvider
.
resource
s
.
map
(
g
=>
{
const
rawResources
=
g
.
resources
.
map
(
r
=>
{
const
uri
=
r
.
uri
.
toString
();
cache
.
set
(
uri
,
r
);
...
...
@@ -164,7 +164,8 @@ export class ExtHostSCM {
return
TPromise
.
as
(
null
);
}
return
asWinJsPromise
(
token
=>
provider
.
open
(
resource
,
token
));
provider
.
open
(
resource
);
return
TPromise
.
as
(
null
);
}
$getOriginalResource
(
handle
:
number
,
uri
:
URI
):
TPromise
<
URI
>
{
...
...
@@ -174,7 +175,7 @@ export class ExtHostSCM {
return
TPromise
.
as
(
null
);
}
return
asWinJsPromise
(
token
=>
provider
.
get
OriginalResource
(
uri
,
token
));
return
asWinJsPromise
(
token
=>
provider
.
provide
OriginalResource
(
uri
,
token
));
}
$onInputBoxValueChange
(
value
:
string
):
TPromise
<
void
>
{
...
...
src/vs/workbench/api/node/mainThreadSCM.ts
浏览文件 @
e06a8382
...
...
@@ -7,6 +7,7 @@
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IThreadService
}
from
'
vs/workbench/services/thread/common/threadService
'
;
import
{
ISCMService
,
ISCMProvider
,
ISCMResource
,
ISCMResourceGroup
}
from
'
vs/workbench/services/scm/common/scm
'
;
...
...
@@ -45,12 +46,13 @@ class MainThreadSCMProvider implements ISCMProvider {
this
.
disposables
.
push
(
scmService
.
registerSCMProvider
(
this
));
}
open
(
resource
:
ISCMResource
):
TPromise
<
void
>
{
open
(
resource
:
ISCMResource
):
void
{
if
(
!
this
.
features
.
supportsOpen
)
{
return
TPromise
.
as
(
null
)
;
return
;
}
return
this
.
proxy
.
$open
(
this
.
handle
,
resource
.
uri
.
toString
());
this
.
proxy
.
$open
(
this
.
handle
,
resource
.
uri
.
toString
())
.
done
(
null
,
onUnexpectedError
);
}
getOriginalResource
(
uri
:
URI
):
TPromise
<
URI
>
{
...
...
src/vs/workbench/services/scm/common/scm.ts
浏览文件 @
e06a8382
...
...
@@ -45,7 +45,7 @@ export interface ISCMProvider extends IDisposable {
readonly
count
?:
number
;
readonly
stateContextKey
?:
string
;
open
(
uri
:
ISCMResource
):
TPromise
<
void
>
;
open
(
uri
:
ISCMResource
):
void
;
getOriginalResource
(
uri
:
URI
):
TPromise
<
URI
>
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录