Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
dde41be0
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,发现更多精彩内容 >>
提交
dde41be0
编写于
8月 05, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Adopt more of `EditorAction._precondition`
上级
c54515ad
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
102 addition
and
99 deletion
+102
-99
src/vs/editor/browser/view/viewImpl.ts
src/vs/editor/browser/view/viewImpl.ts
+2
-4
src/vs/editor/common/commonCodeEditor.ts
src/vs/editor/common/commonCodeEditor.ts
+2
-1
src/vs/editor/common/editorAction.ts
src/vs/editor/common/editorAction.ts
+3
-3
src/vs/editor/common/editorCommon.ts
src/vs/editor/common/editorCommon.ts
+3
-3
src/vs/editor/common/editorCommonExtensions.ts
src/vs/editor/common/editorCommonExtensions.ts
+49
-5
src/vs/editor/contrib/clipboard/browser/clipboard.ts
src/vs/editor/contrib/clipboard/browser/clipboard.ts
+0
-28
src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
...editor/contrib/goToDeclaration/browser/goToDeclaration.ts
+2
-13
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
...editor/contrib/referenceSearch/browser/referenceSearch.ts
+5
-18
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
...ditor/contrib/referenceSearch/browser/referencesWidget.ts
+1
-4
src/vs/editor/contrib/rename/browser/rename.ts
src/vs/editor/contrib/rename/browser/rename.ts
+0
-8
src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts
src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts
+10
-6
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+1
-1
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
+17
-1
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
+6
-3
未找到文件。
src/vs/editor/browser/view/viewImpl.ts
浏览文件 @
dde41be0
...
@@ -89,7 +89,6 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
...
@@ -89,7 +89,6 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
private
accumulatedModelEvents
:
EmitterEvent
[];
private
accumulatedModelEvents
:
EmitterEvent
[];
private
_renderAnimationFrame
:
IDisposable
;
private
_renderAnimationFrame
:
IDisposable
;
private
_keybindingService
:
IKeybindingService
;
private
_editorTextFocusContextKey
:
IKeybindingContextKey
<
boolean
>
;
private
_editorTextFocusContextKey
:
IKeybindingContextKey
<
boolean
>
;
constructor
(
constructor
(
...
@@ -175,8 +174,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
...
@@ -175,8 +174,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
private
createTextArea
(
keybindingService
:
IKeybindingService
):
void
{
private
createTextArea
(
keybindingService
:
IKeybindingService
):
void
{
// Text Area (The focus will always be in the textarea when the cursor is blinking)
// Text Area (The focus will always be in the textarea when the cursor is blinking)
this
.
textArea
=
<
HTMLTextAreaElement
>
document
.
createElement
(
'
textarea
'
);
this
.
textArea
=
<
HTMLTextAreaElement
>
document
.
createElement
(
'
textarea
'
);
this
.
_keybindingService
=
keybindingService
.
createScoped
(
this
.
textArea
);
this
.
_editorTextFocusContextKey
=
EditorContextKeys
.
TextFocus
.
bindTo
(
keybindingService
);
this
.
_editorTextFocusContextKey
=
EditorContextKeys
.
TextFocus
.
bindTo
(
this
.
_keybindingService
);
this
.
textArea
.
className
=
editorBrowser
.
ClassNames
.
TEXTAREA
;
this
.
textArea
.
className
=
editorBrowser
.
ClassNames
.
TEXTAREA
;
this
.
textArea
.
setAttribute
(
'
wrap
'
,
'
off
'
);
this
.
textArea
.
setAttribute
(
'
wrap
'
,
'
off
'
);
this
.
textArea
.
setAttribute
(
'
autocorrect
'
,
'
off
'
);
this
.
textArea
.
setAttribute
(
'
autocorrect
'
,
'
off
'
);
...
@@ -508,7 +506,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
...
@@ -508,7 +506,7 @@ export class View extends ViewEventHandler implements editorBrowser.IView, IDisp
this
.
viewParts
=
[];
this
.
viewParts
=
[];
this
.
layoutProvider
.
dispose
();
this
.
layoutProvider
.
dispose
();
this
.
_
keybindingService
.
dispose
();
this
.
_
editorTextFocusContextKey
.
reset
();
}
}
// --- begin Code Editor APIs
// --- begin Code Editor APIs
...
...
src/vs/editor/common/commonCodeEditor.ts
浏览文件 @
dde41be0
...
@@ -581,7 +581,8 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
...
@@ -581,7 +581,8 @@ export abstract class CommonCodeEditor extends EventEmitter implements editorCom
public
getSupportedActions
():
editorCommon
.
IEditorAction
[]
{
public
getSupportedActions
():
editorCommon
.
IEditorAction
[]
{
let
result
=
this
.
getActions
();
let
result
=
this
.
getActions
();
result
=
result
.
filter
(
action
=>
action
.
isSupported
());
result
=
result
.
filter
(
action
=>
action
.
isSupported
(
true
));
return
result
;
return
result
;
}
}
...
...
src/vs/editor/common/editorAction.ts
浏览文件 @
dde41be0
...
@@ -41,9 +41,9 @@ export class InternalEditorAction extends AbstractInternalEditorAction implement
...
@@ -41,9 +41,9 @@ export class InternalEditorAction extends AbstractInternalEditorAction implement
});
});
}
}
public
isSupported
():
boolean
{
public
isSupported
(
forceEditorTextFocus
:
boolean
):
boolean
{
return
this
.
_instantiationService
.
invokeFunction
((
accessor
)
=>
{
return
this
.
_instantiationService
.
invokeFunction
((
accessor
)
=>
{
return
this
.
_actual
.
supported
(
accessor
,
this
.
_editor
);
return
this
.
_actual
.
supported
(
accessor
,
this
.
_editor
,
forceEditorTextFocus
);
});
});
}
}
...
@@ -68,7 +68,7 @@ export class DynamicEditorAction extends AbstractInternalEditorAction implements
...
@@ -68,7 +68,7 @@ export class DynamicEditorAction extends AbstractInternalEditorAction implements
return
true
;
return
true
;
}
}
public
isSupported
():
boolean
{
public
isSupported
(
forceEditorTextFocus
:
boolean
):
boolean
{
return
true
;
return
true
;
}
}
...
...
src/vs/editor/common/editorCommon.ts
浏览文件 @
dde41be0
...
@@ -3025,12 +3025,12 @@ export namespace EditorContextKeys {
...
@@ -3025,12 +3025,12 @@ export namespace EditorContextKeys {
* A context key that is set when the editor's text has focus (cursor is blinking).
* A context key that is set when the editor's text has focus (cursor is blinking).
* @internal
* @internal
*/
*/
export
const
TextFocus
=
new
KbCtxKey
<
boolean
>
(
'
editorTextFocus
'
,
undefined
);
export
const
TextFocus
=
new
KbCtxKey
<
boolean
>
(
'
editorTextFocus
'
,
false
);
/**
/**
* A context key that is set when the editor's text or an editor's widget has focus.
* A context key that is set when the editor's text or an editor's widget has focus.
* @internal
* @internal
*/
*/
export
const
Focus
=
new
KbCtxKey
<
boolean
>
(
'
editorFocus
'
,
undefined
);
export
const
Focus
=
new
KbCtxKey
<
boolean
>
(
'
editorFocus
'
,
false
);
/**
/**
* A context key that is set when the editor's text is readonly.
* A context key that is set when the editor's text is readonly.
...
@@ -3482,7 +3482,7 @@ export interface IEditorAction {
...
@@ -3482,7 +3482,7 @@ export interface IEditorAction {
label
:
string
;
label
:
string
;
alias
:
string
;
alias
:
string
;
enabled
:
boolean
;
enabled
:
boolean
;
isSupported
():
boolean
;
isSupported
(
forceEditorTextFocus
:
boolean
):
boolean
;
run
():
TPromise
<
void
>
;
run
():
TPromise
<
void
>
;
}
}
...
...
src/vs/editor/common/editorCommonExtensions.ts
浏览文件 @
dde41be0
...
@@ -8,7 +8,7 @@ import {illegalArgument} from 'vs/base/common/errors';
...
@@ -8,7 +8,7 @@ import {illegalArgument} from 'vs/base/common/errors';
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
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServicesAccessor
,
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
KbExpr
,
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
...
@@ -33,13 +33,46 @@ export interface IEditorCommandMenuOptions {
...
@@ -33,13 +33,46 @@ export interface IEditorCommandMenuOptions {
// --- Editor Actions
// --- Editor Actions
// let recorded: EditorAction[] = [];
function
record
(
desc
:
EditorAction
)
{
return
;
// let stack = new Error().stack;
// desc.callsite = stack.split('\n')[3];
// recorded.push(desc);
}
function
analyze
()
{
return
;
// recorded.sort((a, b) => a.id < b.id ? -1 : (a.id > b.id ? 1 : 0));
// recorded.forEach((desc) => {
// let rightpad = (str:string, cnt:number) => {
// while (str.length < cnt) {
// str = str + ' ';
// }
// return str;
// };
// if (typeof desc._precondition === 'undefined') {
// console.warn('MISSING PRECONDITION FOR ' + desc.id + desc.callsite);
// } else {
// let prec = desc._precondition ? desc._precondition.serialize() : 'null';
// if (desc._needsWritableEditor && prec.indexOf('!editorReadonly') === -1) {
// console.warn('BELOW COMMAND DOES NOT PRECONDITION CORRECTLY WRITABLE!');
// }
// console.log(rightpad(desc.id, 50) + '' + desc._needsWritableEditor + '\t\t' + rightpad(prec, 50) + '\t\t' + desc.callsite);
// }
// });
// recorded = [];
}
export
module
CommonEditorRegistry
{
export
module
CommonEditorRegistry
{
export
function
registerEditorAction
(
desc
:
EditorAction
)
{
export
function
registerEditorAction
(
desc
:
EditorAction
)
{
record
(
desc
);
(
<
EditorContributionRegistry
>
Registry
.
as
(
Extensions
.
EditorCommonContributions
)).
registerEditorAction
(
desc
);
(
<
EditorContributionRegistry
>
Registry
.
as
(
Extensions
.
EditorCommonContributions
)).
registerEditorAction
(
desc
);
}
}
export
function
getEditorActions
():
EditorAction
[]
{
export
function
getEditorActions
():
EditorAction
[]
{
analyze
();
return
(
<
EditorContributionRegistry
>
Registry
.
as
(
Extensions
.
EditorCommonContributions
)).
getEditorActions
();
return
(
<
EditorContributionRegistry
>
Registry
.
as
(
Extensions
.
EditorCommonContributions
)).
getEditorActions
();
}
}
...
@@ -152,6 +185,8 @@ export abstract class EditorAction extends ConfigEditorCommand {
...
@@ -152,6 +185,8 @@ export abstract class EditorAction extends ConfigEditorCommand {
public
alias
:
string
;
public
alias
:
string
;
public
menuOpts
:
IEditorCommandMenuOptions
;
public
menuOpts
:
IEditorCommandMenuOptions
;
public
_precondition
:
KbExpr
;
constructor
(
id
:
string
,
label
:
string
,
alias
:
string
,
needsWritableEditor
:
boolean
)
{
constructor
(
id
:
string
,
label
:
string
,
alias
:
string
,
needsWritableEditor
:
boolean
)
{
super
(
id
);
super
(
id
);
this
.
label
=
label
;
this
.
label
=
label
;
...
@@ -170,17 +205,26 @@ export abstract class EditorAction extends ConfigEditorCommand {
...
@@ -170,17 +205,26 @@ export abstract class EditorAction extends ConfigEditorCommand {
}
}
public
enabled
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
public
enabled
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
if
(
!
this
.
supported
(
accessor
,
editor
,
false
))
{
return
false
;
}
if
(
this
.
_needsWritableEditor
)
{
if
(
this
.
_needsWritableEditor
)
{
return
!
editor
.
getConfiguration
().
readOnly
;
return
!
editor
.
getConfiguration
().
readOnly
;
}
}
return
true
;
return
true
;
}
}
public
supported
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
public
supported
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
,
forceEditorTextFocus
:
boolean
):
boolean
{
if
(
this
.
_needsWritableEditor
)
{
const
kbService
=
accessor
.
get
(
IKeybindingService
);
return
!
editor
.
getConfiguration
().
readOnly
;
let
override
=
null
;
if
(
forceEditorTextFocus
)
{
override
=
{
editorTextFocus
:
true
};
}
}
return
true
;
return
kbService
.
contextMatchesRules
(
this
.
_precondition
,
override
);
}
}
public
abstract
run
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
void
|
TPromise
<
void
>
;
public
abstract
run
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
void
|
TPromise
<
void
>
;
...
...
src/vs/editor/contrib/clipboard/browser/clipboard.ts
浏览文件 @
dde41be0
...
@@ -61,20 +61,6 @@ abstract class ClipboardWritingAction extends ExecCommandAction {
...
@@ -61,20 +61,6 @@ abstract class ClipboardWritingAction extends ExecCommandAction {
}
}
}
}
function
editorCursorIsInEditableRange
(
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
let
model
=
editor
.
getModel
();
if
(
!
model
)
{
return
false
;
}
let
hasEditableRange
=
model
.
hasEditableRange
();
if
(
!
hasEditableRange
)
{
return
true
;
}
let
editableRange
=
model
.
getEditableRange
();
let
editorPosition
=
editor
.
getPosition
();
return
editableRange
.
containsPosition
(
editorPosition
);
}
class
ExecCommandCutAction
extends
ClipboardWritingAction
{
class
ExecCommandCutAction
extends
ClipboardWritingAction
{
constructor
()
{
constructor
()
{
...
@@ -101,13 +87,6 @@ class ExecCommandCutAction extends ClipboardWritingAction {
...
@@ -101,13 +87,6 @@ class ExecCommandCutAction extends ClipboardWritingAction {
order
:
1
order
:
1
};
};
}
}
public
enabled
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
if
(
!
super
.
enabled
(
accessor
,
editor
))
{
return
false
;
}
return
editorCursorIsInEditableRange
(
editor
);
}
}
}
class
ExecCommandCopyAction
extends
ClipboardWritingAction
{
class
ExecCommandCopyAction
extends
ClipboardWritingAction
{
...
@@ -164,13 +143,6 @@ class ExecCommandPasteAction extends ExecCommandAction {
...
@@ -164,13 +143,6 @@ class ExecCommandPasteAction extends ExecCommandAction {
order
:
3
order
:
3
};
};
}
}
public
enabled
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
if
(
!
super
.
enabled
(
accessor
,
editor
))
{
return
false
;
}
return
editorCursorIsInEditableRange
(
editor
);
}
}
}
if
(
browser
.
supportsExecCommand
(
'
cut
'
))
{
if
(
browser
.
supportsExecCommand
(
'
cut
'
))
{
...
...
src/vs/editor/contrib/goToDeclaration/browser/goToDeclaration.ts
浏览文件 @
dde41be0
...
@@ -29,8 +29,7 @@ import {getDeclarationsAtPosition} from 'vs/editor/contrib/goToDeclaration/commo
...
@@ -29,8 +29,7 @@ import {getDeclarationsAtPosition} from 'vs/editor/contrib/goToDeclaration/commo
import
{
ReferencesController
}
from
'
vs/editor/contrib/referenceSearch/browser/referencesController
'
;
import
{
ReferencesController
}
from
'
vs/editor/contrib/referenceSearch/browser/referencesController
'
;
import
{
ReferencesModel
}
from
'
vs/editor/contrib/referenceSearch/browser/referencesModel
'
;
import
{
ReferencesModel
}
from
'
vs/editor/contrib/referenceSearch/browser/referencesModel
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IPeekViewService
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
PeekContext
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
optional
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
KbExpr
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
ModeContextKeys
=
editorCommon
.
ModeContextKeys
;
import
ModeContextKeys
=
editorCommon
.
ModeContextKeys
;
...
@@ -196,7 +195,6 @@ export class OpenDefinitionToSideAction extends DefinitionAction {
...
@@ -196,7 +195,6 @@ export class OpenDefinitionToSideAction extends DefinitionAction {
}
}
export
class
PeekDefinitionAction
extends
DefinitionAction
{
export
class
PeekDefinitionAction
extends
DefinitionAction
{
constructor
()
{
constructor
()
{
super
(
super
(
'
editor.action.previewDeclaration
'
,
'
editor.action.previewDeclaration
'
,
...
@@ -205,7 +203,7 @@ export class PeekDefinitionAction extends DefinitionAction {
...
@@ -205,7 +203,7 @@ export class PeekDefinitionAction extends DefinitionAction {
new
DefinitionActionConfig
(
void
0
,
true
,
false
)
new
DefinitionActionConfig
(
void
0
,
true
,
false
)
);
);
this
.
_precondition
=
KbExpr
.
and
(
EditorContextKeys
.
TextFocus
,
ModeContextKeys
.
hasDefinitionProvider
);
this
.
_precondition
=
KbExpr
.
and
(
EditorContextKeys
.
TextFocus
,
ModeContextKeys
.
hasDefinitionProvider
,
PeekContext
.
notInPeekEditor
);
this
.
kbOpts
=
{
this
.
kbOpts
=
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
kbExpr
:
EditorContextKeys
.
TextFocus
,
...
@@ -219,15 +217,6 @@ export class PeekDefinitionAction extends DefinitionAction {
...
@@ -219,15 +217,6 @@ export class PeekDefinitionAction extends DefinitionAction {
kbExpr
:
ModeContextKeys
.
hasDefinitionProvider
kbExpr
:
ModeContextKeys
.
hasDefinitionProvider
};
};
}
}
public
enabled
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
if
(
!
super
.
enabled
(
accessor
,
editor
))
{
return
false
;
}
const
peekViewService
=
accessor
.
get
(
IPeekViewService
,
optional
);
return
(
!
peekViewService
||
!
peekViewService
.
isActive
);
}
}
}
// --- Editor Contribution to goto definition using the mouse and a modifier key
// --- Editor Contribution to goto definition using the mouse and a modifier key
...
...
src/vs/editor/contrib/referenceSearch/browser/referenceSearch.ts
浏览文件 @
dde41be0
...
@@ -17,10 +17,9 @@ import {Position} from 'vs/editor/common/core/position';
...
@@ -17,10 +17,9 @@ import {Position} from 'vs/editor/common/core/position';
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ServicesAccessor
,
EditorAction
,
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
ServicesAccessor
,
EditorAction
,
CommonEditorRegistry
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
Location
,
ReferenceProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
Location
}
from
'
vs/editor/common/modes
'
;
import
{
IPeekViewService
,
getOuterEditor
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
IPeekViewService
,
PeekContext
,
getOuterEditor
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
provideReferences
}
from
'
../common/referenceSearch
'
;
import
{
provideReferences
}
from
'
../common/referenceSearch
'
;
import
{
ReferenceWidget
}
from
'
./referencesWidget
'
;
import
{
ReferencesController
,
RequestOptions
,
ctxReferenceSearchVisible
}
from
'
./referencesController
'
;
import
{
ReferencesController
,
RequestOptions
,
ctxReferenceSearchVisible
}
from
'
./referencesController
'
;
import
{
ReferencesModel
}
from
'
./referencesModel
'
;
import
{
ReferencesModel
}
from
'
./referencesModel
'
;
...
@@ -43,7 +42,7 @@ export class ReferenceController implements editorCommon.IEditorContribution {
...
@@ -43,7 +42,7 @@ export class ReferenceController implements editorCommon.IEditorContribution {
@
optional
(
IPeekViewService
)
peekViewService
:
IPeekViewService
@
optional
(
IPeekViewService
)
peekViewService
:
IPeekViewService
)
{
)
{
if
(
peekViewService
)
{
if
(
peekViewService
)
{
peekViewService
.
contextKey
.
bindTo
(
keybindingService
);
PeekContext
.
inPeekEditor
.
bindTo
(
keybindingService
);
}
}
}
}
...
@@ -65,7 +64,7 @@ export class ReferenceAction extends EditorAction {
...
@@ -65,7 +64,7 @@ export class ReferenceAction extends EditorAction {
false
false
);
);
this
.
_precondition
=
KbExpr
.
and
(
EditorContextKeys
.
TextFocus
,
ModeContextKeys
.
hasReferenceProvider
);
this
.
_precondition
=
KbExpr
.
and
(
EditorContextKeys
.
TextFocus
,
ModeContextKeys
.
hasReferenceProvider
,
PeekContext
.
notInPeekEditor
);
this
.
kbOpts
=
{
this
.
kbOpts
=
{
kbExpr
:
EditorContextKeys
.
TextFocus
,
kbExpr
:
EditorContextKeys
.
TextFocus
,
...
@@ -79,18 +78,6 @@ export class ReferenceAction extends EditorAction {
...
@@ -79,18 +78,6 @@ export class ReferenceAction extends EditorAction {
};
};
}
}
public
enabled
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
boolean
{
if
(
!
super
.
enabled
(
accessor
,
editor
))
{
return
false
;
}
const
peekViewService
=
accessor
.
get
(
IPeekViewService
,
optional
);
if
(
peekViewService
&&
peekViewService
.
isActive
)
{
return
false
;
}
return
ReferenceProviderRegistry
.
has
(
editor
.
getModel
());
}
public
run
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
void
{
public
run
(
accessor
:
ServicesAccessor
,
editor
:
editorCommon
.
ICommonCodeEditor
):
void
{
let
range
=
editor
.
getSelection
();
let
range
=
editor
.
getSelection
();
let
model
=
editor
.
getModel
();
let
model
=
editor
.
getModel
();
...
@@ -187,6 +174,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
...
@@ -187,6 +174,6 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
weight
:
CommonEditorRegistry
.
commandWeight
(
-
101
),
weight
:
CommonEditorRegistry
.
commandWeight
(
-
101
),
primary
:
KeyCode
.
Escape
,
primary
:
KeyCode
.
Escape
,
secondary
:
[
KeyMod
.
Shift
|
KeyCode
.
Escape
],
secondary
:
[
KeyMod
.
Shift
|
KeyCode
.
Escape
],
when
:
KbExpr
.
and
(
ReferenceWidget
.
INNER_EDITOR_CONTEXT_KEY
,
KbExpr
.
not
(
'
config.editor.stablePeek
'
)),
when
:
KbExpr
.
and
(
PeekContext
.
inPeekEditor
,
KbExpr
.
not
(
'
config.editor.stablePeek
'
)),
handler
:
closeActiveReferenceSearch
handler
:
closeActiveReferenceSearch
});
});
src/vs/editor/contrib/referenceSearch/browser/referencesWidget.ts
浏览文件 @
dde41be0
...
@@ -38,7 +38,6 @@ import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
...
@@ -38,7 +38,6 @@ import {ICodeEditor} from 'vs/editor/browser/editorBrowser';
import
{
EmbeddedCodeEditorWidget
}
from
'
vs/editor/browser/widget/embeddedCodeEditorWidget
'
;
import
{
EmbeddedCodeEditorWidget
}
from
'
vs/editor/browser/widget/embeddedCodeEditorWidget
'
;
import
{
PeekViewWidget
,
IPeekViewService
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
PeekViewWidget
,
IPeekViewService
}
from
'
vs/editor/contrib/zoneWidget/browser/peekViewWidget
'
;
import
{
FileReferences
,
OneReference
,
ReferencesModel
}
from
'
./referencesModel
'
;
import
{
FileReferences
,
OneReference
,
ReferencesModel
}
from
'
./referencesModel
'
;
import
{
KbCtxKey
}
from
'
vs/platform/keybinding/common/keybinding
'
;
class
DecorationsManager
implements
IDisposable
{
class
DecorationsManager
implements
IDisposable
{
...
@@ -485,8 +484,6 @@ export interface SelectionEvent {
...
@@ -485,8 +484,6 @@ export interface SelectionEvent {
*/
*/
export
class
ReferenceWidget
extends
PeekViewWidget
{
export
class
ReferenceWidget
extends
PeekViewWidget
{
public
static
INNER_EDITOR_CONTEXT_KEY
=
new
KbCtxKey
<
boolean
>
(
'
inReferenceSearchEditor
'
,
true
);
private
_model
:
ReferencesModel
;
private
_model
:
ReferencesModel
;
private
_decorationsManager
:
DecorationsManager
;
private
_decorationsManager
:
DecorationsManager
;
...
@@ -508,7 +505,7 @@ export class ReferenceWidget extends PeekViewWidget {
...
@@ -508,7 +505,7 @@ export class ReferenceWidget extends PeekViewWidget {
private
_contextService
:
IWorkspaceContextService
,
private
_contextService
:
IWorkspaceContextService
,
private
_instantiationService
:
IInstantiationService
private
_instantiationService
:
IInstantiationService
)
{
)
{
super
(
editor
,
ReferenceWidget
.
INNER_EDITOR_CONTEXT_KEY
,
{
frameColor
:
'
#007ACC
'
,
showFrame
:
false
,
showArrow
:
true
,
isResizeable
:
true
});
super
(
editor
,
{
frameColor
:
'
#007ACC
'
,
showFrame
:
false
,
showArrow
:
true
,
isResizeable
:
true
});
this
.
_instantiationService
=
this
.
_instantiationService
.
createChild
(
new
ServiceCollection
([
IPeekViewService
,
this
]));
this
.
_instantiationService
=
this
.
_instantiationService
.
createChild
(
new
ServiceCollection
([
IPeekViewService
,
this
]));
this
.
create
();
this
.
create
();
...
...
src/vs/editor/contrib/rename/browser/rename.ts
浏览文件 @
dde41be0
...
@@ -19,7 +19,6 @@ import {ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry} fro
...
@@ -19,7 +19,6 @@ import {ServicesAccessor, EditorAction, EditorCommand, CommonEditorRegistry} fro
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
EditorBrowserRegistry
}
from
'
vs/editor/browser/editorBrowserExtensions
'
;
import
{
IRange
,
ICommonCodeEditor
,
EditorContextKeys
,
ModeContextKeys
,
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IRange
,
ICommonCodeEditor
,
EditorContextKeys
,
ModeContextKeys
,
IEditorContribution
}
from
'
vs/editor/common/editorCommon
'
;
import
{
BulkEdit
,
createBulkEdit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
BulkEdit
,
createBulkEdit
}
from
'
vs/editor/common/services/bulkEdit
'
;
import
{
RenameProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
rename
}
from
'
../common/rename
'
;
import
{
rename
}
from
'
../common/rename
'
;
import
RenameInputField
from
'
./renameInputField
'
;
import
RenameInputField
from
'
./renameInputField
'
;
...
@@ -170,13 +169,6 @@ export class RenameAction extends EditorAction {
...
@@ -170,13 +169,6 @@ export class RenameAction extends EditorAction {
};
};
}
}
public
enabled
(
accessor
:
ServicesAccessor
,
editor
:
ICommonCodeEditor
):
boolean
{
if
(
!
super
.
enabled
(
accessor
,
editor
))
{
return
false
;
}
return
RenameProviderRegistry
.
has
(
editor
.
getModel
());
}
public
run
(
accessor
:
ServicesAccessor
,
editor
:
ICommonCodeEditor
):
TPromise
<
void
>
{
public
run
(
accessor
:
ServicesAccessor
,
editor
:
ICommonCodeEditor
):
TPromise
<
void
>
{
return
RenameController
.
get
(
editor
).
run
();
return
RenameController
.
get
(
editor
).
run
();
}
}
...
...
src/vs/editor/contrib/zoneWidget/browser/peekViewWidget.ts
浏览文件 @
dde41be0
...
@@ -19,14 +19,20 @@ import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
...
@@ -19,14 +19,20 @@ import {ICodeEditorService} from 'vs/editor/common/services/codeEditorService';
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
IOptions
,
ZoneWidget
}
from
'
./zoneWidget
'
;
import
{
IOptions
,
ZoneWidget
}
from
'
./zoneWidget
'
;
import
{
EmbeddedCodeEditorWidget
}
from
'
vs/editor/browser/widget/embeddedCodeEditorWidget
'
;
import
{
EmbeddedCodeEditorWidget
}
from
'
vs/editor/browser/widget/embeddedCodeEditorWidget
'
;
import
{
KbCtxKey
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
Kb
Expr
,
Kb
CtxKey
}
from
'
vs/platform/keybinding/common/keybinding
'
;
export
var
IPeekViewService
=
createDecorator
<
IPeekViewService
>
(
'
peekViewService
'
);
export
var
IPeekViewService
=
createDecorator
<
IPeekViewService
>
(
'
peekViewService
'
);
export
namespace
PeekContext
{
export
const
inPeekEditor
=
new
KbCtxKey
<
boolean
>
(
'
inReferenceSearchEditor
'
,
true
);
export
const
notInPeekEditor
:
KbExpr
=
inPeekEditor
.
toNegated
();
}
export
const
NOT_INNER_EDITOR_CONTEXT_KEY
=
new
KbCtxKey
<
boolean
>
(
'
inReferenceSearchEditor
'
,
true
);
export
interface
IPeekViewService
{
export
interface
IPeekViewService
{
_serviceBrand
:
any
;
_serviceBrand
:
any
;
isActive
:
boolean
;
isActive
:
boolean
;
contextKey
:
KbCtxKey
<
boolean
>
;
}
}
export
function
getOuterEditor
(
accessor
:
ServicesAccessor
,
args
:
any
):
ICommonCodeEditor
{
export
function
getOuterEditor
(
accessor
:
ServicesAccessor
,
args
:
any
):
ICommonCodeEditor
{
...
@@ -37,10 +43,9 @@ export function getOuterEditor(accessor: ServicesAccessor, args: any): ICommonCo
...
@@ -37,10 +43,9 @@ export function getOuterEditor(accessor: ServicesAccessor, args: any): ICommonCo
return
editor
;
return
editor
;
}
}
export
class
PeekViewWidget
extends
ZoneWidget
implements
IPeekViewService
{
export
abstract
class
PeekViewWidget
extends
ZoneWidget
implements
IPeekViewService
{
public
_serviceBrand
:
any
;
public
_serviceBrand
:
any
;
public
contextKey
:
KbCtxKey
<
boolean
>
;
private
_onDidClose
=
new
Emitter
<
PeekViewWidget
>
();
private
_onDidClose
=
new
Emitter
<
PeekViewWidget
>
();
private
_isActive
=
false
;
private
_isActive
=
false
;
...
@@ -52,9 +57,8 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
...
@@ -52,9 +57,8 @@ export class PeekViewWidget extends ZoneWidget implements IPeekViewService {
protected
_actionbarWidget
:
ActionBar
;
protected
_actionbarWidget
:
ActionBar
;
protected
_bodyElement
:
HTMLDivElement
;
protected
_bodyElement
:
HTMLDivElement
;
constructor
(
editor
:
ICodeEditor
,
contextKey
:
KbCtxKey
<
boolean
>
,
options
:
IOptions
=
{})
{
constructor
(
editor
:
ICodeEditor
,
options
:
IOptions
=
{})
{
super
(
editor
,
options
);
super
(
editor
,
options
);
this
.
contextKey
=
contextKey
;
}
}
public
dispose
():
void
{
public
dispose
():
void
{
...
...
src/vs/monaco.d.ts
浏览文件 @
dde41be0
...
@@ -2759,7 +2759,7 @@ declare module monaco.editor {
...
@@ -2759,7 +2759,7 @@ declare module monaco.editor {
label
:
string
;
label
:
string
;
alias
:
string
;
alias
:
string
;
enabled
:
boolean
;
enabled
:
boolean
;
isSupported
():
boolean
;
isSupported
(
forceEditorTextFocus
:
boolean
):
boolean
;
run
():
Promise
<
void
>
;
run
():
Promise
<
void
>
;
}
}
...
...
src/vs/platform/keybinding/browser/keybindingServiceImpl.ts
浏览文件 @
dde41be0
...
@@ -186,9 +186,14 @@ export abstract class AbstractKeybindingService {
...
@@ -186,9 +186,14 @@ export abstract class AbstractKeybindingService {
return
new
ScopedKeybindingService
(
this
,
this
.
_onDidChangeContextKey
,
domNode
);
return
new
ScopedKeybindingService
(
this
,
this
.
_onDidChangeContextKey
,
domNode
);
}
}
public
contextMatchesRules
(
rules
:
KbExpr
):
boolean
{
public
contextMatchesRules
(
rules
:
KbExpr
,
overrideKeys
?:
any
):
boolean
{
const
ctx
=
Object
.
create
(
null
);
const
ctx
=
Object
.
create
(
null
);
this
.
getContext
(
this
.
_myContextId
).
fillInContext
(
ctx
);
this
.
getContext
(
this
.
_myContextId
).
fillInContext
(
ctx
);
if
(
overrideKeys
)
{
for
(
let
key
in
overrideKeys
)
{
ctx
[
key
]
=
overrideKeys
[
key
];
}
}
const
result
=
KeybindingResolver
.
contextMatchesRules
(
ctx
,
rules
);
const
result
=
KeybindingResolver
.
contextMatchesRules
(
ctx
,
rules
);
// console.group(rules.serialize() + ' -> ' + result);
// console.group(rules.serialize() + ' -> ' + result);
// rules.keys().forEach(key => { console.log(key, ctx[key]); });
// rules.keys().forEach(key => { console.log(key, ctx[key]); });
...
@@ -257,6 +262,17 @@ export abstract class KeybindingService extends AbstractKeybindingService implem
...
@@ -257,6 +262,17 @@ export abstract class KeybindingService extends AbstractKeybindingService implem
this
.
_commandService
=
commandService
;
this
.
_commandService
=
commandService
;
this
.
_statusService
=
statusService
;
this
.
_statusService
=
statusService
;
this
.
_messageService
=
messageService
;
this
.
_messageService
=
messageService
;
// Uncomment this to see the contexts continuously logged
// let lastLoggedValue: string = null;
// setInterval(() => {
// let values = Object.keys(this._contexts).map((key) => this._contexts[key]);
// let logValue = values.map(v => JSON.stringify(v._value, null, '\t')).join('\n');
// if (lastLoggedValue !== logValue) {
// lastLoggedValue = logValue;
// console.log(lastLoggedValue);
// }
// }, 2000);
}
}
protected
_beginListening
(
domNode
:
HTMLElement
):
void
{
protected
_beginListening
(
domNode
:
HTMLElement
):
void
{
...
...
src/vs/platform/keybinding/common/keybinding.ts
浏览文件 @
dde41be0
...
@@ -478,7 +478,7 @@ export interface IKeybindingService {
...
@@ -478,7 +478,7 @@ export interface IKeybindingService {
onDidChangeContext
:
Event
<
string
[]
>
;
onDidChangeContext
:
Event
<
string
[]
>
;
createKey
<
T
>
(
key
:
string
,
defaultValue
:
T
):
IKeybindingContextKey
<
T
>
;
createKey
<
T
>
(
key
:
string
,
defaultValue
:
T
):
IKeybindingContextKey
<
T
>
;
contextMatchesRules
(
rules
:
KbExpr
):
boolean
;
contextMatchesRules
(
rules
:
KbExpr
,
overrideKeys
?:
any
):
boolean
;
getContextValue
<
T
>
(
key
:
string
):
T
;
getContextValue
<
T
>
(
key
:
string
):
T
;
createScoped
(
domNode
:
IKeybindingScopeLocation
):
IKeybindingService
;
createScoped
(
domNode
:
IKeybindingScopeLocation
):
IKeybindingService
;
...
...
src/vs/workbench/parts/quickopen/browser/commandsHandler.ts
浏览文件 @
dde41be0
...
@@ -19,7 +19,7 @@ import {SyncActionDescriptor, ExecuteCommandAction, IMenuService} from 'vs/platf
...
@@ -19,7 +19,7 @@ import {SyncActionDescriptor, ExecuteCommandAction, IMenuService} from 'vs/platf
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
IWorkbenchActionRegistry
,
Extensions
as
ActionExtensions
}
from
'
vs/workbench/common/actionRegistry
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
QuickOpenHandler
,
QuickOpenAction
}
from
'
vs/workbench/browser/quickopen
'
;
import
{
QuickOpenHandler
,
QuickOpenAction
}
from
'
vs/workbench/browser/quickopen
'
;
import
{
IEditorAction
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorAction
,
IEditor
}
from
'
vs/editor/common/editorCommon
'
;
import
{
matchesWords
,
matchesPrefix
,
matchesContiguousSubString
,
or
}
from
'
vs/base/common/filters
'
;
import
{
matchesWords
,
matchesPrefix
,
matchesContiguousSubString
,
or
}
from
'
vs/base/common/filters
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
...
@@ -268,8 +268,11 @@ export class CommandsHandler extends QuickOpenHandler {
...
@@ -268,8 +268,11 @@ export class CommandsHandler extends QuickOpenHandler {
let
activeEditorControl
=
<
any
>
(
activeEditor
?
activeEditor
.
getControl
()
:
null
);
let
activeEditorControl
=
<
any
>
(
activeEditor
?
activeEditor
.
getControl
()
:
null
);
let
editorActions
:
IEditorAction
[]
=
[];
let
editorActions
:
IEditorAction
[]
=
[];
if
(
activeEditorControl
&&
types
.
isFunction
(
activeEditorControl
.
getSupportedActions
))
{
if
(
activeEditorControl
)
{
editorActions
=
activeEditorControl
.
getSupportedActions
();
let
editor
=
<
IEditor
>
activeEditorControl
;
if
(
types
.
isFunction
(
editor
.
getSupportedActions
))
{
editorActions
=
editor
.
getSupportedActions
();
}
}
}
let
editorEntries
=
this
.
editorActionsToEntries
(
editorActions
,
searchValue
);
let
editorEntries
=
this
.
editorActionsToEntries
(
editorActions
,
searchValue
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录