Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
e05566c9
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,发现更多精彩内容 >>
提交
e05566c9
编写于
5月 02, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Command handlers are invoked with var-args
上级
fb467cc7
变更
17
显示空白变更内容
内联
并排
Showing
17 changed file
with
45 addition
and
52 deletion
+45
-52
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+1
-0
src/vs/editor/common/config/config.ts
src/vs/editor/common/config/config.ts
+1
-1
src/vs/editor/common/editorCommonExtensions.ts
src/vs/editor/common/editorCommonExtensions.ts
+3
-6
src/vs/editor/contrib/accessibility/browser/accessibility.ts
src/vs/editor/contrib/accessibility/browser/accessibility.ts
+1
-1
src/vs/editor/contrib/codelens/browser/codelens.ts
src/vs/editor/contrib/codelens/browser/codelens.ts
+1
-1
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
...editor/contrib/referenceSearch/browser/referenceSearch.ts
+7
-7
src/vs/editor/contrib/suggest/browser/suggest.ts
src/vs/editor/contrib/suggest/browser/suggest.ts
+1
-1
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
+15
-16
src/vs/platform/keybinding/common/keybindingService.ts
src/vs/platform/keybinding/common/keybindingService.ts
+3
-3
src/vs/platform/keybinding/test/common/mockKeybindingService.ts
.../platform/keybinding/test/common/mockKeybindingService.ts
+1
-1
src/vs/platform/opener/electron-browser/openerService.ts
src/vs/platform/opener/electron-browser/openerService.ts
+4
-1
src/vs/workbench/api/node/extHostCommands.ts
src/vs/workbench/api/node/extHostCommands.ts
+1
-1
src/vs/workbench/common/actionRegistry.ts
src/vs/workbench/common/actionRegistry.ts
+1
-1
src/vs/workbench/electron-browser/actions.ts
src/vs/workbench/electron-browser/actions.ts
+1
-4
src/vs/workbench/parts/html/browser/html.contribution.ts
src/vs/workbench/parts/html/browser/html.contribution.ts
+1
-3
src/vs/workbench/parts/themes/test/electron-browser/themes.test.contribution.ts
.../themes/test/electron-browser/themes.test.contribution.ts
+2
-4
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
...services/keybinding/electron-browser/keybindingService.ts
+1
-1
未找到文件。
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
e05566c9
...
...
@@ -556,6 +556,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements IActionPr
}
public
trigger
(
source
:
string
,
handlerId
:
string
,
payload
:
any
):
void
{
payload
=
payload
||
{};
var
candidate
=
this
.
getAction
(
handlerId
);
if
(
candidate
!==
null
)
{
if
(
candidate
.
enabled
)
{
...
...
src/vs/editor/common/config/config.ts
浏览文件 @
e05566c9
...
...
@@ -83,7 +83,7 @@ function registerCoreDispatchCommand2(handlerId: string) {
id
:
'
default:
'
+
handlerId
,
handler
:
(
accessor
:
ServicesAccessor
,
args
:
any
)
=>
{
withCodeEditorFromCommandHandler
(
handlerId
,
accessor
,
(
editor
)
=>
{
editor
.
trigger
(
'
keyboard
'
,
handlerId
,
args
[
0
]
);
editor
.
trigger
(
'
keyboard
'
,
handlerId
,
args
);
});
},
weight
:
KeybindingsRegistry
.
WEIGHT
.
editorCore
(),
...
...
src/vs/editor/common/editorCommonExtensions.ts
浏览文件 @
e05566c9
...
...
@@ -93,11 +93,8 @@ export module CommonEditorRegistry {
export
function
registerLanguageCommand
(
id
:
string
,
handler
:
(
accessor
:
ServicesAccessor
,
args
:
{
[
n
:
string
]:
any
})
=>
any
)
{
KeybindingsRegistry
.
registerCommandDesc
({
id
,
handler
(
accessor
,
args
:
any
[])
{
if
(
args
&&
args
.
length
>
1
||
typeof
args
[
0
]
!==
'
object
'
)
{
throw
illegalArgument
();
}
return
handler
(
accessor
,
args
&&
args
[
0
]);
handler
(
accessor
,
args
:
any
)
{
return
handler
(
accessor
,
args
||
{});
},
weight
:
KeybindingsRegistry
.
WEIGHT
.
editorContrib
(),
primary
:
undefined
,
...
...
@@ -255,7 +252,7 @@ function whenRule(needsTextFocus: boolean, needsKey: string): KbExpr {
function
createCommandHandler
(
commandId
:
string
,
handler
:
IEditorCommandHandler
):
ICommandHandler
{
return
(
accessor
,
args
)
=>
{
withCodeEditorFromCommandHandler
(
commandId
,
accessor
,
(
editor
)
=>
{
handler
(
accessor
,
editor
,
args
);
handler
(
accessor
,
editor
,
args
||
{}
);
});
};
}
src/vs/editor/contrib/accessibility/browser/accessibility.ts
浏览文件 @
e05566c9
...
...
@@ -232,7 +232,7 @@ CommonEditorRegistry.registerEditorCommand('closeAccessibilityHelp', CommonEdito
});
KeybindingsRegistry
.
registerCommandDesc
({
id
:
TOGGLE_EXPERIMENTAL_SCREEN_READER_SUPPORT_COMMAND_ID
,
handler
:
(
accessor
:
ServicesAccessor
,
args
:
any
)
=>
{
handler
:
(
accessor
:
ServicesAccessor
)
=>
{
let
currentValue
=
GlobalScreenReaderNVDA
.
getValue
();
GlobalScreenReaderNVDA
.
setValue
(
!
currentValue
);
},
...
...
src/vs/editor/contrib/codelens/browser/codelens.ts
浏览文件 @
e05566c9
...
...
@@ -79,7 +79,7 @@ class CodeLensContentWidget implements editorBrowser.IContentWidget {
let
command
=
this
.
_commands
[
element
.
id
];
if
(
command
)
{
editor
.
focus
();
keybindingService
.
executeCommand
(
command
.
id
,
command
.
arguments
).
done
(
undefined
,
err
=>
{
keybindingService
.
executeCommand
(
command
.
id
,
...
command
.
arguments
).
done
(
undefined
,
err
=>
{
messageService
.
show
(
Severity
.
Error
,
err
);
});
}
...
...
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
浏览文件 @
e05566c9
...
...
@@ -32,6 +32,7 @@ import {IPeekViewService, getOuterEditor} from 'vs/editor/contrib/zoneWidget/bro
import
{
findReferences
}
from
'
../common/referenceSearch
'
;
import
{
EventType
,
ReferencesModel
}
from
'
./referenceSearchModel
'
;
import
{
ReferenceWidget
}
from
'
./referenceSearchWidget
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
export
class
FindReferencesController
implements
editorCommon
.
IEditorContribution
{
...
...
@@ -317,9 +318,8 @@ function metaTitle(references: IReference[]): string {
}
}
let
findReferencesCommand
:
ICommandHandler
=
(
accessor
,
args
:[
URI
,
editorCommon
.
IPosition
]
)
=>
{
let
findReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
editorCommon
.
IPosition
)
=>
{
let
[
resource
,
position
]
=
args
;
if
(
!
(
resource
instanceof
URI
))
{
throw
new
Error
(
'
illegal argument, uri
'
);
}
...
...
@@ -341,12 +341,12 @@ let findReferencesCommand: ICommandHandler = (accessor, args:[URI, editorCommon.
});
};
let
showReferencesCommand
:
ICommandHandler
=
(
accessor
,
args
:[
URI
,
editorCommon
.
IPosition
,
IReference
[]
])
=>
{
if
(
!
(
args
[
0
]
instanceof
URI
))
{
let
showReferencesCommand
:
ICommandHandler
=
(
accessor
:
ServicesAccessor
,
resource
:
URI
,
position
:
editorCommon
.
IPosition
,
references
:
IReference
[
])
=>
{
if
(
!
(
resource
instanceof
URI
))
{
throw
new
Error
(
'
illegal argument, uri expected
'
);
}
return
accessor
.
get
(
IEditorService
).
openEditor
({
resource
:
args
[
0
]
}).
then
(
editor
=>
{
return
accessor
.
get
(
IEditorService
).
openEditor
({
resource
:
resource
}).
then
(
editor
=>
{
let
control
=
<
editorCommon
.
ICommonCodeEditor
>
editor
.
getControl
();
if
(
!
control
||
typeof
control
.
getEditorType
!==
'
function
'
)
{
...
...
@@ -354,8 +354,8 @@ let showReferencesCommand: ICommandHandler = (accessor, args:[URI, editorCommon.
}
let
controller
=
FindReferencesController
.
getController
(
control
);
let
range
=
Position
.
asEmptyRange
(
args
[
1
]
);
return
TPromise
.
as
(
controller
.
processRequest
(
Range
.
lift
(
range
),
TPromise
.
as
(
args
[
2
]
),
metaTitle
)).
then
(()
=>
true
);
let
range
=
Position
.
asEmptyRange
(
position
);
return
TPromise
.
as
(
controller
.
processRequest
(
Range
.
lift
(
range
),
TPromise
.
as
(
references
),
metaTitle
)).
then
(()
=>
true
);
});
};
...
...
src/vs/editor/contrib/suggest/browser/suggest.ts
浏览文件 @
e05566c9
...
...
@@ -227,7 +227,7 @@ CommonEditorRegistry.registerEditorCommand(ACCEPT_SELECTED_SUGGESTION_CMD, weigh
});
KeybindingsRegistry
.
registerCommandDesc
({
id
:
'
acceptSelectedSuggestionOnEnter
'
,
handler
(
accessor
,
args
)
{
handler
(
accessor
)
{
withCodeEditorFromCommandHandler
(
'
acceptSelectedSuggestionOnEnter
'
,
accessor
,
(
editor
)
=>
{
const
controller
=
SuggestController
.
getSuggestController
(
editor
);
controller
.
acceptSelectedSuggestion
();
...
...
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
浏览文件 @
e05566c9
...
...
@@ -21,6 +21,7 @@ import {KeybindingsRegistry} from 'vs/platform/keybinding/common/keybindingsRegi
import
{
IStatusbarService
}
from
'
vs/platform/statusbar/common/statusbar
'
;
import
{
IMessageService
}
from
'
vs/platform/message/common/message
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
let
KEYBINDING_CONTEXT_ATTR
=
'
data-keybinding-context
'
;
...
...
@@ -332,20 +333,20 @@ export abstract class KeybindingService extends AbstractKeybindingService implem
e
.
preventDefault
();
}
let
commandId
=
resolveResult
.
commandId
.
replace
(
/^
\^
/
,
''
);
this
.
_invokeHandler
(
commandId
,
{
context
:
contextValue
}
).
done
(
undefined
,
err
=>
{
this
.
_invokeHandler
(
commandId
,
[{}]
).
done
(
undefined
,
err
=>
{
this
.
_messageService
.
show
(
Severity
.
Warning
,
err
);
});
}
}
protected
_invokeHandler
(
commandId
:
string
,
args
:
any
):
TPromise
<
any
>
{
protected
_invokeHandler
(
commandId
:
string
,
args
:
any
[]
):
TPromise
<
any
>
{
let
handler
=
this
.
_getCommandHandler
(
commandId
);
if
(
!
handler
)
{
return
TPromise
.
wrapError
(
new
Error
(
`No handler found for the command: '
${
commandId
}
'. An extension might be missing an activation event.`
));
}
try
{
let
result
=
this
.
_instantiationService
.
invokeFunction
(
handler
,
args
);
let
result
=
this
.
_instantiationService
.
invokeFunction
.
apply
(
this
.
_instantiationService
,
[
handler
].
concat
(
args
)
);
return
TPromise
.
as
(
result
);
}
catch
(
err
)
{
return
TPromise
.
wrapError
(
err
);
...
...
@@ -376,23 +377,21 @@ export abstract class KeybindingService extends AbstractKeybindingService implem
delete
this
.
_contexts
[
String
(
contextId
)];
}
public
executeCommand
(
commandId
:
string
,
args
:
any
=
{}):
TPromise
<
any
>
{
// TODO@{Alex,Joh} we should spec what args should be.
// TODO@Alex - move this to its own command
if
(
commandId
===
SET_CONTEXT_COMMAND_ID
)
{
var
contextKey
=
String
(
args
[
0
]);
var
contextValue
=
args
[
1
];
this
.
setContext
(
contextKey
,
contextValue
);
return
TPromise
.
as
(
null
);
}
public
executeCommand
(
commandId
:
string
,
...
args
:
any
[]):
TPromise
<
any
>
{
return
this
.
_invokeHandler
(
commandId
,
args
);
}
}
KeybindingsRegistry
.
registerCommandDesc
({
id
:
SET_CONTEXT_COMMAND_ID
,
handler
:
(
accessor
:
ServicesAccessor
,
contextKey
:
any
,
contextValue
:
any
)
=>
{
accessor
.
get
(
IKeybindingService
).
createKey
(
String
(
contextKey
),
contextValue
);
},
weight
:
0
,
primary
:
undefined
,
when
:
null
});
class
ScopedKeybindingService
extends
AbstractKeybindingService
{
private
_parent
:
AbstractKeybindingService
;
...
...
src/vs/platform/keybinding/common/keybindingService.ts
浏览文件 @
e05566c9
...
...
@@ -292,7 +292,7 @@ export interface IKeybindingItem {
}
export
interface
ICommandHandler
{
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
;
(
accessor
:
ServicesAccessor
,
...
args
:
any
[]
):
void
;
description
?:
string
|
ICommandHandlerDescription
;
}
...
...
@@ -335,8 +335,8 @@ export interface IKeybindingService {
getHTMLLabelFor
(
keybinding
:
Keybinding
):
IHTMLContentElement
[];
getElectronAcceleratorFor
(
keybinding
:
Keybinding
):
string
;
executeCommand
<
T
>
(
commandId
:
string
,
args
?:
any
):
TPromise
<
T
>
;
executeCommand
(
commandId
:
string
,
args
?:
any
):
TPromise
<
any
>
;
executeCommand
<
T
>
(
commandId
:
string
,
...
args
:
any
[]
):
TPromise
<
T
>
;
executeCommand
(
commandId
:
string
,
...
args
:
any
[]
):
TPromise
<
any
>
;
hasCommand
(
commandId
:
string
):
boolean
;
}
...
...
src/vs/platform/keybinding/test/common/mockKeybindingService.ts
浏览文件 @
e05566c9
...
...
@@ -33,7 +33,7 @@ export class MockKeybindingService implements IKeybindingService {
public
serviceId
=
IKeybindingService
;
public
dispose
():
void
{
}
public
executeCommand
(
commandId
:
string
,
args
:
any
):
TPromise
<
any
>
{
return
;
}
public
executeCommand
(
commandId
:
string
,
...
args
:
any
[]
):
TPromise
<
any
>
{
return
;
}
public
hasCommand
(
commandId
)
{
return
false
;
}
public
createKey
<
T
>
(
key
:
string
,
defaultValue
:
T
):
IKeybindingContextKey
<
T
>
{
...
...
src/vs/platform/opener/electron-browser/openerService.ts
浏览文件 @
e05566c9
...
...
@@ -36,10 +36,13 @@ export class OpenerService implements IOpenerService {
let
args
:
any
;
try
{
args
=
parse
(
query
);
if
(
!
Array
.
isArray
(
args
))
{
args
=
[
args
];
}
}
catch
(
e
)
{
//
}
promise
=
this
.
_keybindingService
.
executeCommand
(
path
,
args
);
promise
=
this
.
_keybindingService
.
executeCommand
(
path
,
...
args
);
}
else
{
promise
=
this
.
_editorService
.
resolveEditorModel
({
resource
}).
then
(
model
=>
{
...
...
src/vs/workbench/api/node/extHostCommands.ts
浏览文件 @
e05566c9
...
...
@@ -157,7 +157,7 @@ export class MainThreadCommands {
}
$executeCommand
<
T
>
(
id
:
string
,
args
:
any
[]):
Thenable
<
T
>
{
return
this
.
_keybindingService
.
executeCommand
(
id
,
args
);
return
this
.
_keybindingService
.
executeCommand
(
id
,
...
args
);
}
$getCommands
():
Thenable
<
string
[]
>
{
...
...
src/vs/workbench/common/actionRegistry.ts
浏览文件 @
e05566c9
...
...
@@ -169,7 +169,7 @@ export function triggerAndDisposeAction(instantitationService: IInstantiationSer
}
if
(
telemetryService
)
{
telemetryService
.
publicLog
(
'
workbenchActionExecuted
'
,
{
id
:
actionInstance
.
id
,
from
:
args
.
from
||
'
keybinding
'
});
telemetryService
.
publicLog
(
'
workbenchActionExecuted
'
,
{
id
:
actionInstance
.
id
,
from
:
args
&&
args
.
from
||
'
keybinding
'
});
}
// run action when workbench is created
...
...
src/vs/workbench/electron-browser/actions.ts
浏览文件 @
e05566c9
...
...
@@ -469,10 +469,7 @@ export class CloseMessagesAction extends Action {
KeybindingsRegistry
.
registerCommandDesc
({
id
:
'
_workbench.ipc
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
0
),
handler
(
accessor
:
ServicesAccessor
,
args
:
[
string
,
any
[]])
{
const
ipcMessage
=
args
[
0
];
const
ipcArgs
=
args
[
1
];
handler
(
accessor
:
ServicesAccessor
,
ipcMessage
:
string
,
ipcArgs
:
any
[])
{
if
(
ipcMessage
&&
Array
.
isArray
(
ipcArgs
))
{
ipc
.
send
(
ipcMessage
,
...
ipcArgs
);
}
else
{
...
...
src/vs/workbench/parts/html/browser/html.contribution.ts
浏览文件 @
e05566c9
...
...
@@ -28,9 +28,7 @@ import {SyncDescriptor} from 'vs/platform/instantiation/common/descriptors';
KeybindingsRegistry
.
registerCommandDesc
({
id
:
'
_workbench.previewHtml
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
0
),
handler
(
accessor
:
ServicesAccessor
,
args
:
[
URI
|
string
,
EditorPosition
])
{
let
[
resource
,
position
]
=
args
;
handler
(
accessor
:
ServicesAccessor
,
resource
:
URI
|
string
,
position
:
EditorPosition
)
{
let
uri
=
resource
instanceof
URI
?
resource
:
URI
.
parse
(
resource
);
let
input
=
accessor
.
get
(
IInstantiationService
).
createInstance
(
HtmlInput
,
uri
.
fsPath
,
undefined
,
uri
);
...
...
src/vs/workbench/parts/themes/test/electron-browser/themes.test.contribution.ts
浏览文件 @
e05566c9
...
...
@@ -150,7 +150,7 @@ class Snapper {
KeybindingsRegistry
.
registerCommandDesc
({
id
:
'
_workbench.captureSyntaxTokens
'
,
weight
:
KeybindingsRegistry
.
WEIGHT
.
workbenchContrib
(
0
),
handler
(
accessor
:
ServicesAccessor
,
args
:
[
URI
]
)
{
handler
(
accessor
:
ServicesAccessor
,
resource
:
URI
)
{
let
process
=
(
resource
:
URI
)
=>
{
let
filePath
=
resource
.
fsPath
;
...
...
@@ -160,10 +160,8 @@ KeybindingsRegistry.registerCommandDesc({
return
pfs
.
readFile
(
filePath
).
then
(
content
=>
{
return
snapper
.
captureSyntaxTokens
(
fileName
,
content
.
toString
());
});
}
};
let
[
resource
]
=
args
;
if
(
!
resource
)
{
let
editorService
=
accessor
.
get
(
IWorkbenchEditorService
);
let
fileEditorInput
=
asFileEditorInput
(
editorService
.
getActiveEditorInput
());
...
...
src/vs/workbench/services/keybinding/electron-browser/keybindingService.ts
浏览文件 @
e05566c9
...
...
@@ -250,7 +250,7 @@ export class WorkbenchKeybindingService extends KeybindingService {
return
commandAdded
;
}
protected
_invokeHandler
(
commandId
:
string
,
args
:
any
):
TPromise
<
any
>
{
protected
_invokeHandler
(
commandId
:
string
,
args
:
any
[]
):
TPromise
<
any
>
{
if
(
this
.
_extensionService
)
{
return
this
.
_extensionService
.
activateByEvent
(
'
onCommand:
'
+
commandId
).
then
(
_
=>
{
return
super
.
_invokeHandler
(
commandId
,
args
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录