Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e465e920
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,发现更多精彩内容 >>
提交
e465e920
编写于
11月 22, 2019
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "simplify how alternative commands are defined, #73081"
This reverts commit
a88a14d6
.
上级
48192594
变更
1
显示空白变更内容
内联
并排
Showing
1 changed file
with
34 addition
and
14 deletion
+34
-14
src/vs/editor/contrib/gotoSymbol/goToCommands.ts
src/vs/editor/contrib/gotoSymbol/goToCommands.ts
+34
-14
未找到文件。
src/vs/editor/contrib/gotoSymbol/goToCommands.ts
浏览文件 @
e465e920
...
...
@@ -49,16 +49,15 @@ export interface SymbolNavigationActionConfig {
openToSide
:
boolean
;
openInPeek
:
boolean
;
muteMessage
:
boolean
;
alternativeCommand
?:
string
;
}
abstract
class
SymbolNavigationAction
extends
EditorAction
{
private
readonly
_config
:
SymbolNavigationActionConfig
;
private
readonly
_config
uration
:
SymbolNavigationActionConfig
;
constructor
(
configuration
:
SymbolNavigationActionConfig
,
opts
:
IActionOptions
)
{
super
(
opts
);
this
.
_config
=
configuration
;
this
.
_config
uration
=
configuration
;
}
run
(
accessor
:
ServicesAccessor
,
editor
:
ICodeEditor
):
Promise
<
void
>
{
...
...
@@ -84,11 +83,11 @@ abstract class SymbolNavigationAction extends EditorAction {
alert
(
references
.
ariaMessage
);
const
referenceCount
=
references
.
references
.
length
;
const
altAction
=
references
.
referenceAt
(
model
.
uri
,
pos
)
&&
editor
.
getAction
(
this
.
_
config
.
alternativeCommand
||
''
);
const
altAction
=
references
.
referenceAt
(
model
.
uri
,
pos
)
&&
editor
.
getAction
(
this
.
_
getAlternativeCommand
()
);
if
(
referenceCount
===
0
)
{
// no result -> show message
if
(
!
this
.
_config
.
muteMessage
)
{
if
(
!
this
.
_config
uration
.
muteMessage
)
{
const
info
=
model
.
getWordAtPosition
(
pos
);
MessageController
.
get
(
editor
).
showMessage
(
this
.
_getNoResultFoundMessage
(
info
),
pos
);
}
...
...
@@ -116,18 +115,20 @@ abstract class SymbolNavigationAction extends EditorAction {
protected
abstract
_getNoResultFoundMessage
(
info
:
IWordAtPosition
|
null
):
string
;
protected
abstract
_getAlternativeCommand
():
string
;
protected
abstract
_getGoToPreference
(
editor
:
IActiveCodeEditor
):
GoToLocationValues
;
private
async
_onResult
(
editorService
:
ICodeEditorService
,
symbolNavService
:
ISymbolNavigationService
,
editor
:
IActiveCodeEditor
,
model
:
ReferencesModel
):
Promise
<
void
>
{
const
gotoLocation
=
this
.
_getGoToPreference
(
editor
);
if
(
this
.
_config
.
openInPeek
||
(
gotoLocation
===
'
peek
'
&&
model
.
references
.
length
>
1
))
{
if
(
this
.
_config
uration
.
openInPeek
||
(
gotoLocation
===
'
peek
'
&&
model
.
references
.
length
>
1
))
{
this
.
_openInPeek
(
editor
,
model
);
}
else
{
const
next
=
model
.
firstReference
()
!
;
const
peek
=
model
.
references
.
length
>
1
&&
gotoLocation
===
'
gotoAndPeek
'
;
const
targetEditor
=
await
this
.
_openReference
(
editor
,
editorService
,
next
,
this
.
_config
.
openToSide
,
!
peek
);
const
targetEditor
=
await
this
.
_openReference
(
editor
,
editorService
,
next
,
this
.
_config
uration
.
openToSide
,
!
peek
);
if
(
peek
&&
targetEditor
)
{
this
.
_openInPeek
(
targetEditor
,
model
);
}
else
{
...
...
@@ -181,7 +182,7 @@ abstract class SymbolNavigationAction extends EditorAction {
private
_openInPeek
(
target
:
ICodeEditor
,
model
:
ReferencesModel
)
{
let
controller
=
ReferencesController
.
get
(
target
);
if
(
controller
&&
target
.
hasModel
())
{
controller
.
toggleWidget
(
target
.
getSelection
(),
createCancelablePromise
(
_
=>
Promise
.
resolve
(
model
)),
this
.
_config
.
openInPeek
);
controller
.
toggleWidget
(
target
.
getSelection
(),
createCancelablePromise
(
_
=>
Promise
.
resolve
(
model
)),
this
.
_config
uration
.
openInPeek
);
}
else
{
model
.
dispose
();
}
...
...
@@ -202,6 +203,10 @@ export class DefinitionAction extends SymbolNavigationAction {
:
nls
.
localize
(
'
generic.noResults
'
,
"
No definition found
"
);
}
protected
_getAlternativeCommand
():
string
{
return
'
editor.action.goToReferences
'
;
}
protected
_getGoToPreference
(
editor
:
IActiveCodeEditor
):
GoToLocationValues
{
return
editor
.
getOption
(
EditorOption
.
gotoLocation
).
multipleDefinitions
;
}
...
...
@@ -219,8 +224,7 @@ registerEditorAction(class GoToDefinitionAction extends DefinitionAction {
super
({
openToSide
:
false
,
openInPeek
:
false
,
muteMessage
:
false
,
alternativeCommand
:
'
editor.action.goToReferences
'
muteMessage
:
false
},
{
id
:
GoToDefinitionAction
.
id
,
label
:
nls
.
localize
(
'
actions.goToDecl.label
'
,
"
Go to Definition
"
),
...
...
@@ -323,6 +327,10 @@ class DeclarationAction extends SymbolNavigationAction {
:
nls
.
localize
(
'
decl.generic.noResults
'
,
"
No declaration found
"
);
}
protected
_getAlternativeCommand
():
string
{
return
'
editor.action.goToReferences
'
;
}
protected
_getGoToPreference
(
editor
:
IActiveCodeEditor
):
GoToLocationValues
{
return
editor
.
getOption
(
EditorOption
.
gotoLocation
).
multipleDeclarations
;
}
...
...
@@ -336,8 +344,7 @@ registerEditorAction(class GoToDeclarationAction extends DeclarationAction {
super
({
openToSide
:
false
,
openInPeek
:
false
,
muteMessage
:
false
,
alternativeCommand
:
'
editor.action.goToReferences
'
muteMessage
:
false
},
{
id
:
GoToDeclarationAction
.
id
,
label
:
nls
.
localize
(
'
actions.goToDeclaration.label
'
,
"
Go to Declaration
"
),
...
...
@@ -405,6 +412,10 @@ class TypeDefinitionAction extends SymbolNavigationAction {
:
nls
.
localize
(
'
goToTypeDefinition.generic.noResults
'
,
"
No type definition found
"
);
}
protected
_getAlternativeCommand
():
string
{
return
'
editor.action.goToReferences
'
;
}
protected
_getGoToPreference
(
editor
:
IActiveCodeEditor
):
GoToLocationValues
{
return
editor
.
getOption
(
EditorOption
.
gotoLocation
).
multipleTypeDefinitions
;
}
...
...
@@ -418,8 +429,7 @@ registerEditorAction(class GoToTypeDefinitionAction extends TypeDefinitionAction
super
({
openToSide
:
false
,
openInPeek
:
false
,
muteMessage
:
false
,
alternativeCommand
:
'
editor.action.goToReferences
'
muteMessage
:
false
},
{
id
:
GoToTypeDefinitionAction
.
ID
,
label
:
nls
.
localize
(
'
actions.goToTypeDefinition.label
'
,
"
Go to Type Definition
"
),
...
...
@@ -488,6 +498,10 @@ class ImplementationAction extends SymbolNavigationAction {
:
nls
.
localize
(
'
goToImplementation.generic.noResults
'
,
"
No implementation found
"
);
}
protected
_getAlternativeCommand
():
string
{
return
''
;
}
protected
_getGoToPreference
(
editor
:
IActiveCodeEditor
):
GoToLocationValues
{
return
editor
.
getOption
(
EditorOption
.
gotoLocation
).
multipleImplementations
;
}
...
...
@@ -575,6 +589,10 @@ class ReferencesAction extends SymbolNavigationAction {
:
nls
.
localize
(
'
references.noGeneric
'
,
"
No references found
"
);
}
protected
_getAlternativeCommand
():
string
{
return
''
;
}
protected
_getGoToPreference
(
editor
:
IActiveCodeEditor
):
GoToLocationValues
{
return
editor
.
getOption
(
EditorOption
.
gotoLocation
).
multipleReferences
;
}
...
...
@@ -676,6 +694,8 @@ class GenericGoToLocationAction extends SymbolNavigationAction {
protected
_getGoToPreference
(
editor
:
IActiveCodeEditor
):
GoToLocationValues
{
return
this
.
_gotoMultipleBehaviour
??
editor
.
getOption
(
EditorOption
.
gotoLocation
).
multipleReferences
;
}
protected
_getAlternativeCommand
()
{
return
''
;
}
}
CommandsRegistry
.
registerCommand
({
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录