Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e784ae60
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,发现更多精彩内容 >>
提交
e784ae60
编写于
8月 08, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More cleanup
上级
ce86f17e
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
41 addition
and
72 deletion
+41
-72
src/vs/editor/browser/widget/codeEditorWidget.ts
src/vs/editor/browser/widget/codeEditorWidget.ts
+1
-1
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+3
-6
src/vs/editor/common/config/config.ts
src/vs/editor/common/config/config.ts
+7
-1
src/vs/editor/common/editorAction.ts
src/vs/editor/common/editorAction.ts
+18
-18
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+1
-2
src/vs/editor/common/editorCommonExtensions.ts
src/vs/editor/common/editorCommonExtensions.ts
+1
-26
src/vs/editor/contrib/comment/common/comment.ts
src/vs/editor/contrib/comment/common/comment.ts
+1
-1
src/vs/editor/contrib/quickOpen/browser/quickCommand.ts
src/vs/editor/contrib/quickOpen/browser/quickCommand.ts
+5
-7
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+1
-2
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
+1
-6
src/vs/platform/keybinding/common/keybinding.ts
src/vs/platform/keybinding/common/keybinding.ts
+1
-1
src/vs/workbench/parts/quickopen/browser/commandsHandler.ts
src/vs/workbench/parts/quickopen/browser/commandsHandler.ts
+1
-1
未找到文件。
src/vs/editor/browser/widget/codeEditorWidget.ts
浏览文件 @
e784ae60
...
...
@@ -109,7 +109,7 @@ export class CodeEditorWidget extends CommonCodeEditor implements editorBrowser.
}
CommonEditorRegistry
.
getEditorActions
().
forEach
((
action
)
=>
{
let
internalAction
=
new
InternalEditorAction
(
action
,
this
,
this
.
_instantiationService
);
let
internalAction
=
new
InternalEditorAction
(
action
,
this
,
this
.
_instantiationService
,
this
.
_keybindingService
);
this
.
_actions
[
internalAction
.
id
]
=
internalAction
;
});
}
...
...
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
e784ae60
...
...
@@ -582,7 +582,7 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
public
getSupportedActions
():
editorCommon
.
IEditorAction
[]
{
let
result
=
this
.
getActions
();
result
=
result
.
filter
(
action
=>
action
.
isSupported
(
true
));
result
=
result
.
filter
(
action
=>
action
.
isSupported
());
return
result
;
}
...
...
@@ -594,11 +594,8 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
public
trigger
(
source
:
string
,
handlerId
:
string
,
payload
:
any
):
void
{
payload
=
payload
||
{};
var
candidate
=
this
.
getAction
(
handlerId
);
if
(
candidate
!==
null
)
{
if
(
candidate
.
enabled
)
{
this
.
_telemetryService
.
publicLog
(
'
editorActionInvoked
'
,
{
name
:
candidate
.
label
,
id
:
candidate
.
id
}
);
TPromise
.
as
(
candidate
.
run
()).
done
(
null
,
onUnexpectedError
);
}
if
(
candidate
!==
null
)
{
TPromise
.
as
(
candidate
.
run
()).
done
(
null
,
onUnexpectedError
);
}
else
{
if
(
!
this
.
cursor
)
{
return
;
...
...
src/vs/editor/common/config/config.ts
浏览文件 @
e784ae60
...
...
@@ -8,7 +8,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
IEditorService
}
from
'
vs/platform/editor/common/editor
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindings
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
IKeybinding
Service
,
IKeybinding
s
,
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ICommandAndKeybindingRule
,
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
...
...
@@ -111,6 +111,12 @@ export abstract class EditorCommand extends Command {
return
;
}
return
editor
.
invokeWithinContext
((
editorAccessor
)
=>
{
const
kbService
=
accessor
.
get
(
IKeybindingService
);
if
(
!
kbService
.
contextMatchesRules
(
this
.
precondition
))
{
// precondition does not hold
return
;
}
return
this
.
runEditorCommand
(
editorAccessor
,
editor
,
args
);
});
}
...
...
src/vs/editor/common/editorAction.ts
浏览文件 @
e784ae60
...
...
@@ -8,6 +8,7 @@ import {TPromise} from 'vs/base/common/winjs.base';
import
{
IActionDescriptor
,
ICommonCodeEditor
,
IEditorAction
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
EditorAction
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
export
abstract
class
AbstractInternalEditorAction
{
...
...
@@ -28,28 +29,31 @@ export class InternalEditorAction extends AbstractInternalEditorAction implement
private
_actual
:
EditorAction
;
private
_instantiationService
:
IInstantiationService
;
constructor
(
actual
:
EditorAction
,
editor
:
ICommonCodeEditor
,
instantiationService
:
IInstantiationService
)
{
private
_keybindingService
:
IKeybindingService
;
constructor
(
actual
:
EditorAction
,
editor
:
ICommonCodeEditor
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IKeybindingService
keybindingService
:
IKeybindingService
)
{
super
(
actual
.
id
,
actual
.
label
,
actual
.
alias
,
editor
);
this
.
_actual
=
actual
;
this
.
_instantiationService
=
instantiationService
;
this
.
_keybindingService
=
keybindingService
;
}
public
get
enabled
():
boolean
{
return
this
.
_instantiationService
.
invokeFunction
((
accessor
)
=>
{
return
this
.
_actual
.
enabled
(
accessor
,
this
.
_editor
);
});
}
public
isSupported
(
forceEditorTextFocus
:
boolean
):
boolean
{
return
this
.
_instantiationService
.
invokeFunction
((
accessor
)
=>
{
return
this
.
_actual
.
supported
(
accessor
,
this
.
_editor
,
forceEditorTextFocus
);
});
public
isSupported
():
boolean
{
return
this
.
_keybindingService
.
contextMatchesRules
(
this
.
_actual
.
precondition
);
}
public
run
():
TPromise
<
void
>
{
if
(
!
this
.
isSupported
())
{
return
TPromise
.
as
(
void
0
);
}
return
this
.
_instantiationService
.
invokeFunction
((
accessor
)
=>
{
return
TPromise
.
as
(
this
.
_actual
.
run
(
accessor
,
this
.
_editor
));
return
TPromise
.
as
(
this
.
_actual
.
run
EditorCommand
(
accessor
,
this
.
_editor
,
null
));
});
}
}
...
...
@@ -64,11 +68,7 @@ export class DynamicEditorAction extends AbstractInternalEditorAction implements
this
.
_run
=
descriptor
.
run
;
}
public
get
enabled
():
boolean
{
return
true
;
}
public
isSupported
(
forceEditorTextFocus
:
boolean
):
boolean
{
public
isSupported
():
boolean
{
return
true
;
}
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
e784ae60
...
...
@@ -3481,8 +3481,7 @@ export interface IEditorAction {
id
:
string
;
label
:
string
;
alias
:
string
;
enabled
:
boolean
;
isSupported
(
forceEditorTextFocus
:
boolean
):
boolean
;
isSupported
():
boolean
;
run
():
TPromise
<
void
>
;
}
...
...
src/vs/editor/common/editorCommonExtensions.ts
浏览文件 @
e784ae60
...
...
@@ -8,7 +8,6 @@ import {illegalArgument} from 'vs/base/common/errors';
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
...
...
@@ -171,35 +170,11 @@ export abstract class EditorAction extends ConfigEditorCommand {
};
}
protected
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
,
args
:
any
):
void
|
TPromise
<
void
>
{
if
(
!
this
.
enabled
(
accessor
,
editor
))
{
return
;
}
public
runEditorCommand
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
,
args
:
any
):
void
|
TPromise
<
void
>
{
accessor
.
get
(
ITelemetryService
).
publicLog
(
'
editorActionInvoked
'
,
{
name
:
this
.
label
,
id
:
this
.
id
});
return
this
.
run
(
accessor
,
editor
);
}
public
enabled
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
if
(
!
this
.
supported
(
accessor
,
editor
,
false
))
{
return
false
;
}
return
true
;
}
public
supported
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
,
forceEditorTextFocus
:
boolean
):
boolean
{
const
kbService
=
accessor
.
get
(
IKeybindingService
);
let
override
=
null
;
if
(
forceEditorTextFocus
)
{
override
=
{
editorTextFocus
:
true
};
}
return
kbService
.
contextMatchesRules
(
this
.
precondition
,
override
);
}
public
abstract
run
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
void
|
TPromise
<
void
>
;
}
...
...
src/vs/editor/contrib/comment/common/comment.ts
浏览文件 @
e784ae60
...
...
@@ -75,7 +75,7 @@ class RemoveLineCommentAction extends CommentLineAction {
id
:
'
editor.action.removeCommentLine
'
,
label
:
nls
.
localize
(
'
comment.line.remove
'
,
"
Remove Line Comment
"
),
alias
:
'
Remove Line Comment
'
,
precondition
:
EditorContextKeys
.
Writable
precondition
:
EditorContextKeys
.
Writable
,
kbOpts
:
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
primary
:
KeyMod
.
chord
(
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_K
,
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_U
)
...
...
src/vs/editor/contrib/quickOpen/browser/quickCommand.ts
浏览文件 @
e784ae60
...
...
@@ -52,13 +52,11 @@ export class EditorActionCommandEntry extends QuickOpenEntryGroup {
// Some actions are enabled only when editor has focus
this
.
editor
.
focus
();
if
(
this
.
action
.
enabled
)
{
try
{
let
promise
=
this
.
action
.
run
()
||
TPromise
.
as
(
null
);
promise
.
done
(
null
,
onUnexpectedError
);
}
catch
(
error
)
{
onUnexpectedError
(
error
);
}
try
{
let
promise
=
this
.
action
.
run
()
||
TPromise
.
as
(
null
);
promise
.
done
(
null
,
onUnexpectedError
);
}
catch
(
error
)
{
onUnexpectedError
(
error
);
}
},
onUnexpectedError
);
...
...
src/vs/monaco.d.ts
浏览文件 @
e784ae60
...
...
@@ -2758,8 +2758,7 @@ declare module monaco.editor {
id
:
string
;
label
:
string
;
alias
:
string
;
enabled
:
boolean
;
isSupported
(
forceEditorTextFocus
:
boolean
):
boolean
;
isSupported
():
boolean
;
run
():
Promise
<
void
>
;
}
...
...
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
浏览文件 @
e784ae60
...
...
@@ -186,14 +186,9 @@ export abstract class AbstractKeybindingService {
return
new
ScopedKeybindingService
(
this
,
this
.
_onDidChangeContextKey
,
domNode
);
}
public
contextMatchesRules
(
rules
:
KbExpr
,
overrideKeys
?:
any
):
boolean
{
public
contextMatchesRules
(
rules
:
KbExpr
):
boolean
{
const
ctx
=
Object
.
create
(
null
);
this
.
getContext
(
this
.
_myContextId
).
fillInContext
(
ctx
);
if
(
overrideKeys
)
{
for
(
let
key
in
overrideKeys
)
{
ctx
[
key
]
=
overrideKeys
[
key
];
}
}
const
result
=
KeybindingResolver
.
contextMatchesRules
(
ctx
,
rules
);
// console.group(rules.serialize() + ' -> ' + result);
// rules.keys().forEach(key => { console.log(key, ctx[key]); });
...
...
src/vs/platform/keybinding/common/keybinding.ts
浏览文件 @
e784ae60
...
...
@@ -478,7 +478,7 @@ export interface IKeybindingService {
onDidChangeContext
:
Event
<
string
[]
>
;
createKey
<
T
>
(
key
:
string
,
defaultValue
:
T
):
IKeybindingContextKey
<
T
>
;
contextMatchesRules
(
rules
:
KbExpr
,
overrideKeys
?:
any
):
boolean
;
contextMatchesRules
(
rules
:
KbExpr
):
boolean
;
getContextValue
<
T
>
(
key
:
string
):
T
;
createScoped
(
domNode
:
IKeybindingScopeLocation
):
IKeybindingService
;
...
...
src/vs/workbench/parts/quickopen/browser/commandsHandler.ts
浏览文件 @
e784ae60
...
...
@@ -187,7 +187,7 @@ class EditorActionCommandEntry extends BaseCommandEntry {
if
(
mode
===
Mode
.
OPEN
)
{
// Use a timeout to give the quick open widget a chance to close itself first
TPromise
.
timeout
(
50
).
done
(()
=>
{
if
(
this
.
action
&&
this
.
action
.
enabled
)
{
if
(
this
.
action
)
{
try
{
this
.
telemetryService
.
publicLog
(
'
workbenchActionExecuted
'
,
{
id
:
this
.
action
.
id
,
from
:
'
quick open
'
});
(
this
.
action
.
run
()
||
TPromise
.
as
(
null
)).
done
(
null
,
(
err
)
=>
this
.
onError
(
err
));
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录