Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
82d255a3
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,发现更多精彩内容 >>
未验证
提交
82d255a3
编写于
2月 12, 2021
作者:
J
João Moreno
浏览文件
操作
浏览文件
下载
差异文件
Merge branch 'joao/overlay-cks'
上级
968ce642
bc72e7ab
变更
15
隐藏空白更改
内联
并排
Showing
15 changed file
with
164 addition
and
100 deletion
+164
-100
src/vs/editor/browser/widget/diffEditorWidget.ts
src/vs/editor/browser/widget/diffEditorWidget.ts
+11
-21
src/vs/platform/contextkey/browser/contextKeyService.ts
src/vs/platform/contextkey/browser/contextKeyService.ts
+95
-19
src/vs/platform/contextkey/common/contextkey.ts
src/vs/platform/contextkey/common/contextkey.ts
+3
-2
src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts
.../keybinding/test/common/abstractKeybindingService.test.ts
+1
-0
src/vs/platform/keybinding/test/common/mockKeybindingService.ts
.../platform/keybinding/test/common/mockKeybindingService.ts
+3
-0
src/vs/workbench/browser/parts/views/treeView.ts
src/vs/workbench/browser/parts/views/treeView.ts
+5
-5
src/vs/workbench/browser/parts/views/viewPane.ts
src/vs/workbench/browser/parts/views/viewPane.ts
+1
-5
src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
...workbench/contrib/extensions/browser/extensionsActions.ts
+12
-11
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
...orkbench/contrib/notebook/browser/notebookEditorWidget.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
...h/contrib/notebook/browser/view/renderers/markdownCell.ts
+3
-2
src/vs/workbench/contrib/remote/browser/tunnelView.ts
src/vs/workbench/contrib/remote/browser/tunnelView.ts
+7
-9
src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts
src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts
+5
-5
src/vs/workbench/contrib/scm/browser/menus.ts
src/vs/workbench/contrib/scm/browser/menus.ts
+9
-12
src/vs/workbench/contrib/timeline/browser/timelinePane.ts
src/vs/workbench/contrib/timeline/browser/timelinePane.ts
+5
-5
未找到文件。
src/vs/editor/browser/widget/diffEditorWidget.ts
浏览文件 @
82d255a3
...
...
@@ -222,7 +222,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
private
readonly
_updateDecorationsRunner
:
RunOnceScheduler
;
private
readonly
_editorWorkerService
:
IEditorWorkerService
;
protected
_contextKeyService
:
IContextKeyService
;
private
readonly
_contextKeyService
:
IContextKeyService
;
private
readonly
_instantiationService
:
IInstantiationService
;
private
readonly
_codeEditorService
:
ICodeEditorService
;
private
readonly
_themeService
:
IThemeService
;
private
readonly
_notificationService
:
INotificationService
;
...
...
@@ -248,6 +249,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this
.
_editorWorkerService
=
editorWorkerService
;
this
.
_codeEditorService
=
codeEditorService
;
this
.
_contextKeyService
=
this
.
_register
(
contextKeyService
.
createScoped
(
domElement
));
this
.
_instantiationService
=
instantiationService
.
createChild
(
new
ServiceCollection
([
IContextKeyService
,
this
.
_contextKeyService
]));
this
.
_contextKeyService
.
createKey
(
'
isInDiffEditor
'
,
true
);
this
.
_themeService
=
themeService
;
this
.
_notificationService
=
notificationService
;
...
...
@@ -354,20 +356,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this
.
_diffComputationResult
=
null
;
const
leftContextKeyService
=
this
.
_contextKeyService
.
createScoped
();
const
leftServices
=
new
ServiceCollection
();
leftServices
.
set
(
IContextKeyService
,
leftContextKeyService
);
const
leftScopedInstantiationService
=
instantiationService
.
createChild
(
leftServices
);
const
rightContextKeyService
=
this
.
_contextKeyService
.
createScoped
();
const
rightServices
=
new
ServiceCollection
();
rightServices
.
set
(
IContextKeyService
,
rightContextKeyService
);
const
rightScopedInstantiationService
=
instantiationService
.
createChild
(
rightServices
);
this
.
_originalEditor
=
this
.
_createLeftHandSideEditor
(
options
,
codeEditorWidgetOptions
.
originalEditor
||
{},
leftScopedInstantiationService
,
leftContextKeyService
);
this
.
_modifiedEditor
=
this
.
_createRightHandSideEditor
(
options
,
codeEditorWidgetOptions
.
modifiedEditor
||
{},
rightScopedInstantiationService
,
rightContextKeyService
);
this
.
_originalEditor
=
this
.
_createLeftHandSideEditor
(
options
,
codeEditorWidgetOptions
.
originalEditor
||
{});
this
.
_modifiedEditor
=
this
.
_createRightHandSideEditor
(
options
,
codeEditorWidgetOptions
.
modifiedEditor
||
{});
this
.
_originalOverviewRuler
=
null
;
this
.
_modifiedOverviewRuler
=
null
;
...
...
@@ -495,8 +485,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this
.
_layoutOverviewRulers
();
}
private
_createLeftHandSideEditor
(
options
:
Readonly
<
editorBrowser
.
IDiffEditorConstructionOptions
>
,
codeEditorWidgetOptions
:
ICodeEditorWidgetOptions
,
instantiationService
:
IInstantiationService
,
contextKeyService
:
IContextKeyService
):
CodeEditorWidget
{
const
editor
=
this
.
_createInnerEditor
(
instantiationService
,
this
.
_originalDomNode
,
this
.
_adjustOptionsForLeftHandSide
(
options
),
codeEditorWidgetOptions
);
private
_createLeftHandSideEditor
(
options
:
Readonly
<
editorBrowser
.
IDiffEditorConstructionOptions
>
,
codeEditorWidgetOptions
:
ICodeEditorWidgetOptions
):
CodeEditorWidget
{
const
editor
=
this
.
_createInnerEditor
(
this
.
_
instantiationService
,
this
.
_originalDomNode
,
this
.
_adjustOptionsForLeftHandSide
(
options
),
codeEditorWidgetOptions
);
this
.
_register
(
editor
.
onDidScrollChange
((
e
)
=>
{
if
(
this
.
_isHandlingScrollEvent
)
{
...
...
@@ -538,7 +528,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
}
}));
const
isInDiffLeftEditorKey
=
contextKeyService
.
createKey
<
boolean
>
(
'
isInDiffLeftEditor
'
,
undefined
);
const
isInDiffLeftEditorKey
=
this
.
_contextKeyService
.
createKey
<
boolean
>
(
'
isInDiffLeftEditor
'
,
editor
.
hasWidgetFocus
()
);
this
.
_register
(
editor
.
onDidFocusEditorWidget
(()
=>
isInDiffLeftEditorKey
.
set
(
true
)));
this
.
_register
(
editor
.
onDidBlurEditorWidget
(()
=>
isInDiffLeftEditorKey
.
set
(
false
)));
...
...
@@ -557,8 +547,8 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
return
editor
;
}
private
_createRightHandSideEditor
(
options
:
Readonly
<
editorBrowser
.
IDiffEditorConstructionOptions
>
,
codeEditorWidgetOptions
:
ICodeEditorWidgetOptions
,
instantiationService
:
IInstantiationService
,
contextKeyService
:
IContextKeyService
):
CodeEditorWidget
{
const
editor
=
this
.
_createInnerEditor
(
instantiationService
,
this
.
_modifiedDomNode
,
this
.
_adjustOptionsForRightHandSide
(
options
),
codeEditorWidgetOptions
);
private
_createRightHandSideEditor
(
options
:
Readonly
<
editorBrowser
.
IDiffEditorConstructionOptions
>
,
codeEditorWidgetOptions
:
ICodeEditorWidgetOptions
):
CodeEditorWidget
{
const
editor
=
this
.
_createInnerEditor
(
this
.
_
instantiationService
,
this
.
_modifiedDomNode
,
this
.
_adjustOptionsForRightHandSide
(
options
),
codeEditorWidgetOptions
);
this
.
_register
(
editor
.
onDidScrollChange
((
e
)
=>
{
if
(
this
.
_isHandlingScrollEvent
)
{
...
...
@@ -606,7 +596,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
}
}));
const
isInDiffRightEditorKey
=
contextKeyService
.
createKey
<
boolean
>
(
'
isInDiffRightEditor
'
,
undefined
);
const
isInDiffRightEditorKey
=
this
.
_contextKeyService
.
createKey
<
boolean
>
(
'
isInDiffRightEditor
'
,
editor
.
hasWidgetFocus
()
);
this
.
_register
(
editor
.
onDidFocusEditorWidget
(()
=>
isInDiffRightEditorKey
.
set
(
true
)));
this
.
_register
(
editor
.
onDidBlurEditorWidget
(()
=>
isInDiffRightEditorKey
.
set
(
false
)));
...
...
src/vs/platform/contextkey/browser/contextKeyService.ts
浏览文件 @
82d255a3
...
...
@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Emitter
,
PauseableEmitter
}
from
'
vs/base/common/event
'
;
import
{
Emitter
,
Event
,
PauseableEmitter
}
from
'
vs/base/common/event
'
;
import
{
Iterable
}
from
'
vs/base/common/iterator
'
;
import
{
IDisposable
,
DisposableStore
,
MutableDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
TernarySearchTree
}
from
'
vs/base/common/map
'
;
...
...
@@ -287,6 +287,13 @@ export abstract class AbstractContextKeyService implements IContextKeyService {
return
new
ScopedContextKeyService
(
this
,
domNode
);
}
createOverlay
(
overlay
:
Iterable
<
[
string
,
any
]
>
=
Iterable
.
empty
()):
IContextKeyService
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
`AbstractContextKeyService has been disposed`
);
}
return
new
OverlayContextKeyService
(
this
,
overlay
);
}
public
contextMatchesRules
(
rules
:
ContextKeyExpression
|
undefined
):
boolean
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
`AbstractContextKeyService has been disposed`
);
...
...
@@ -405,27 +412,25 @@ export class ContextKeyService extends AbstractContextKeyService implements ICon
class
ScopedContextKeyService
extends
AbstractContextKeyService
{
private
_parent
:
AbstractContextKeyService
;
private
_domNode
:
IContextKeyServiceTarget
|
undefined
;
private
_domNode
:
IContextKeyServiceTarget
;
private
readonly
_parentChangeListener
=
new
MutableDisposable
();
constructor
(
parent
:
AbstractContextKeyService
,
domNode
?
:
IContextKeyServiceTarget
)
{
constructor
(
parent
:
AbstractContextKeyService
,
domNode
:
IContextKeyServiceTarget
)
{
super
(
parent
.
createChildContext
());
this
.
_parent
=
parent
;
this
.
_updateParentChangeListener
();
if
(
domNode
)
{
this
.
_domNode
=
domNode
;
if
(
this
.
_domNode
.
hasAttribute
(
KEYBINDING_CONTEXT_ATTR
))
{
let
extraInfo
=
''
;
if
((
this
.
_domNode
as
HTMLElement
).
classList
)
{
extraInfo
=
Array
.
from
((
this
.
_domNode
as
HTMLElement
).
classList
.
values
()).
join
(
'
,
'
);
}
console
.
error
(
`Element already has context attribute
${
extraInfo
?
'
:
'
+
extraInfo
:
''
}
`
);
this
.
_domNode
=
domNode
;
if
(
this
.
_domNode
.
hasAttribute
(
KEYBINDING_CONTEXT_ATTR
))
{
let
extraInfo
=
''
;
if
((
this
.
_domNode
as
HTMLElement
).
classList
)
{
extraInfo
=
Array
.
from
((
this
.
_domNode
as
HTMLElement
).
classList
.
values
()).
join
(
'
,
'
);
}
this
.
_domNode
.
setAttribute
(
KEYBINDING_CONTEXT_ATTR
,
String
(
this
.
_myContextId
));
console
.
error
(
`Element already has context attribute
${
extraInfo
?
'
:
'
+
extraInfo
:
''
}
`
);
}
this
.
_domNode
.
setAttribute
(
KEYBINDING_CONTEXT_ATTR
,
String
(
this
.
_myContextId
));
}
private
_updateParentChangeListener
():
void
{
...
...
@@ -434,14 +439,15 @@ class ScopedContextKeyService extends AbstractContextKeyService {
}
public
dispose
():
void
{
if
(
this
.
_isDisposed
)
{
return
;
}
this
.
_onDidChangeContext
.
dispose
();
this
.
_isDisposed
=
true
;
this
.
_parent
.
disposeContext
(
this
.
_myContextId
);
this
.
_parentChangeListener
?.
dispose
();
if
(
this
.
_domNode
)
{
this
.
_domNode
.
removeAttribute
(
KEYBINDING_CONTEXT_ATTR
);
this
.
_domNode
=
undefined
;
}
this
.
_parentChangeListener
.
dispose
();
this
.
_domNode
.
removeAttribute
(
KEYBINDING_CONTEXT_ATTR
);
this
.
_isDisposed
=
true
;
}
public
getContextValuesContainer
(
contextId
:
number
):
Context
{
...
...
@@ -484,6 +490,76 @@ class ScopedContextKeyService extends AbstractContextKeyService {
}
}
class
OverlayContext
implements
IContext
{
constructor
(
private
parent
:
IContext
,
private
overlay
:
ReadonlyMap
<
string
,
any
>
)
{
}
getValue
<
T
>
(
key
:
string
):
T
|
undefined
{
return
this
.
overlay
.
has
(
key
)
?
this
.
overlay
.
get
(
key
)
:
this
.
parent
.
getValue
(
key
);
}
}
class
OverlayContextKeyService
implements
IContextKeyService
{
declare
_serviceBrand
:
undefined
;
private
overlay
:
Map
<
string
,
any
>
;
get
contextId
():
number
{
return
this
.
parent
.
contextId
;
}
get
onDidChangeContext
():
Event
<
IContextKeyChangeEvent
>
{
return
this
.
parent
.
onDidChangeContext
;
}
constructor
(
private
parent
:
AbstractContextKeyService
|
OverlayContextKeyService
,
overlay
:
Iterable
<
[
string
,
any
]
>
)
{
this
.
overlay
=
new
Map
(
overlay
);
}
bufferChangeEvents
(
callback
:
Function
):
void
{
this
.
parent
.
bufferChangeEvents
(
callback
);
}
createKey
<
T
>
():
IContextKey
<
T
>
{
throw
new
Error
(
'
Not supported.
'
);
}
getContext
(
target
:
IContextKeyServiceTarget
|
null
):
IContext
{
return
new
OverlayContext
(
this
.
parent
.
getContext
(
target
),
this
.
overlay
);
}
getContextValuesContainer
(
contextId
:
number
):
IContext
{
const
parentContext
=
this
.
parent
.
getContextValuesContainer
(
contextId
);
return
new
OverlayContext
(
parentContext
,
this
.
overlay
);
}
contextMatchesRules
(
rules
:
ContextKeyExpression
|
undefined
):
boolean
{
const
context
=
this
.
getContextValuesContainer
(
this
.
contextId
);
const
result
=
KeybindingResolver
.
contextMatchesRules
(
context
,
rules
);
return
result
;
}
getContextKeyValue
<
T
>
(
key
:
string
):
T
|
undefined
{
return
this
.
overlay
.
has
(
key
)
?
this
.
overlay
.
get
(
key
)
:
this
.
parent
.
getContextKeyValue
(
key
);
}
createScoped
():
IContextKeyService
{
throw
new
Error
(
'
Not supported.
'
);
}
createOverlay
(
overlay
:
Iterable
<
[
string
,
any
]
>
=
Iterable
.
empty
()):
IContextKeyService
{
return
new
OverlayContextKeyService
(
this
,
overlay
);
}
updateParent
():
void
{
throw
new
Error
(
'
Not supported.
'
);
}
dispose
():
void
{
// noop
}
}
function
findContextAttr
(
domNode
:
IContextKeyServiceTarget
|
null
):
number
{
while
(
domNode
)
{
if
(
domNode
.
hasAttribute
(
KEYBINDING_CONTEXT_ATTR
))
{
...
...
src/vs/platform/contextkey/common/contextkey.ts
浏览文件 @
82d255a3
...
...
@@ -1273,7 +1273,7 @@ export class RawContextKey<T> extends ContextKeyDefinedExpr {
private
readonly
_defaultValue
:
T
|
undefined
;
constructor
(
key
:
string
,
defaultValue
:
T
|
undefined
,
description
?:
string
)
{
constructor
(
readonly
key
:
string
,
defaultValue
:
T
|
undefined
,
description
?:
string
)
{
super
(
key
);
this
.
_defaultValue
=
defaultValue
;
...
...
@@ -1341,7 +1341,8 @@ export interface IContextKeyService {
contextMatchesRules
(
rules
:
ContextKeyExpression
|
undefined
):
boolean
;
getContextKeyValue
<
T
>
(
key
:
string
):
T
|
undefined
;
createScoped
(
target
?:
IContextKeyServiceTarget
):
IContextKeyService
;
createScoped
(
target
:
IContextKeyServiceTarget
):
IContextKeyService
;
createOverlay
(
overlay
:
Iterable
<
[
string
,
any
]
>
):
IContextKeyService
;
getContext
(
target
:
IContextKeyServiceTarget
|
null
):
IContext
;
updateParent
(
parentContextKeyService
:
IContextKeyService
):
void
;
...
...
src/vs/platform/keybinding/test/common/abstractKeybindingService.test.ts
浏览文件 @
82d255a3
...
...
@@ -118,6 +118,7 @@ suite('AbstractKeybindingService', () => {
contextMatchesRules
:
undefined
!
,
getContextKeyValue
:
undefined
!
,
createScoped
:
undefined
!
,
createOverlay
:
undefined
!
,
getContext
:
(
target
:
IContextKeyServiceTarget
):
any
=>
{
return
currentContextValue
;
},
...
...
src/vs/platform/keybinding/test/common/mockKeybindingService.ts
浏览文件 @
82d255a3
...
...
@@ -66,6 +66,9 @@ export class MockContextKeyService implements IContextKeyService {
public
createScoped
(
domNode
:
HTMLElement
):
IContextKeyService
{
return
this
;
}
public
createOverlay
():
IContextKeyService
{
return
this
;
}
updateParent
(
_parentContextKeyService
:
IContextKeyService
):
void
{
// no-op
}
...
...
src/vs/workbench/browser/parts/views/treeView.ts
浏览文件 @
82d255a3
...
...
@@ -1123,18 +1123,18 @@ class TreeMenus extends Disposable implements IDisposable {
if
(
!
this
.
contextKeyService
)
{
return
{
primary
:
[],
secondary
:
[]
};
}
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
();
contextKeyService
.
createKey
(
'
view
'
,
this
.
id
);
contextKeyService
.
createKey
(
context
.
key
,
context
.
value
);
const
contextKeyService
=
this
.
contextKeyService
.
createOverlay
([
[
'
view
'
,
this
.
id
],
[
context
.
key
,
context
.
value
]
]);
const
menu
=
this
.
menuService
.
createMenu
(
menuId
,
contextKeyService
);
const
primary
:
IAction
[]
=
[];
const
secondary
:
IAction
[]
=
[];
const
result
=
{
primary
,
secondary
};
createAndFillInContextMenuActions
(
menu
,
{
shouldForwardArgs
:
true
},
result
,
g
=>
/^inline/
.
test
(
g
));
menu
.
dispose
();
contextKeyService
.
dispose
();
return
result
;
}
...
...
src/vs/workbench/browser/parts/views/viewPane.ts
浏览文件 @
82d255a3
...
...
@@ -80,16 +80,12 @@ class ViewWelcomeController {
return
visibleItems
.
map
(
v
=>
v
.
descriptor
);
}
private
contextKeyService
:
IContextKeyService
;
private
disposables
=
new
DisposableStore
();
constructor
(
private
id
:
string
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
,
@
IContextKeyService
private
contextKeyService
:
IContextKeyService
,
)
{
this
.
contextKeyService
=
contextKeyService
.
createScoped
();
this
.
disposables
.
add
(
this
.
contextKeyService
);
contextKeyService
.
onDidChangeContext
(
this
.
onDidChangeContext
,
this
,
this
.
disposables
);
Event
.
filter
(
viewsRegistry
.
onDidChangeViewWelcomeContent
,
id
=>
id
===
this
.
id
)(
this
.
onDidChangeViewWelcomeContent
,
this
,
this
.
disposables
);
this
.
onDidChangeViewWelcomeContent
();
...
...
src/vs/workbench/contrib/extensions/browser/extensionsActions.ts
浏览文件 @
82d255a3
...
...
@@ -859,25 +859,27 @@ export class DropDownMenuActionViewItem extends ExtensionActionViewItem {
export
function
getContextMenuActions
(
extension
:
IExtension
|
undefined
|
null
,
inExtensionEditor
:
boolean
,
instantiationService
:
IInstantiationService
):
IAction
[][]
{
return
instantiationService
.
invokeFunction
(
accessor
=>
{
const
scopedContextKeyService
=
accessor
.
get
(
IContextKeyService
).
createScoped
();
const
menuService
=
accessor
.
get
(
IMenuService
);
const
extensionRecommendationsService
=
accessor
.
get
(
IExtensionRecommendationsService
);
const
extensionIgnoredRecommendationsService
=
accessor
.
get
(
IExtensionIgnoredRecommendationsService
);
const
cksOverlay
:
[
string
,
any
][]
=
[];
if
(
extension
)
{
scopedContextKeyService
.
createKey
<
string
>
(
'
extension
'
,
extension
.
identifier
.
id
);
scopedContextKeyService
.
createKey
<
boolean
>
(
'
isBuiltinExtension
'
,
extension
.
isBuiltin
);
scopedContextKeyService
.
createKey
<
boolean
>
(
'
extensionHasConfiguration
'
,
extension
.
local
&&
!!
extension
.
local
.
manifest
.
contributes
&&
!!
extension
.
local
.
manifest
.
contributes
.
configuration
);
scopedContextKeyService
.
createKey
<
boolean
>
(
'
isExtensionRecommended
'
,
!!
extensionRecommendationsService
.
getAllRecommendationsWithReason
()[
extension
.
identifier
.
id
.
toLowerCase
()
]);
scopedContextKeyService
.
createKey
<
boolean
>
(
'
isExtensionWorkspaceRecommended
'
,
extensionRecommendationsService
.
getAllRecommendationsWithReason
()[
extension
.
identifier
.
id
.
toLowerCase
()]?.
reasonId
===
ExtensionRecommendationReason
.
Workspace
);
scopedContextKeyService
.
createKey
<
boolean
>
(
'
isUserIgnoredRecommendation
'
,
extensionIgnoredRecommendationsService
.
globalIgnoredRecommendations
.
some
(
e
=>
e
===
extension
.
identifier
.
id
.
toLowerCase
())
);
scopedContextKeyService
.
createKey
<
boolean
>
(
'
inExtensionEditor
'
,
inExtensionEditor
);
cksOverlay
.
push
([
'
extension
'
,
extension
.
identifier
.
id
]
);
cksOverlay
.
push
([
'
isBuiltinExtension
'
,
extension
.
isBuiltin
]
);
cksOverlay
.
push
([
'
extensionHasConfiguration
'
,
extension
.
local
&&
!!
extension
.
local
.
manifest
.
contributes
&&
!!
extension
.
local
.
manifest
.
contributes
.
configuration
]
);
cksOverlay
.
push
([
'
isExtensionRecommended
'
,
!!
extensionRecommendationsService
.
getAllRecommendationsWithReason
()[
extension
.
identifier
.
id
.
toLowerCase
()]
]);
cksOverlay
.
push
([
'
isExtensionWorkspaceRecommended
'
,
extensionRecommendationsService
.
getAllRecommendationsWithReason
()[
extension
.
identifier
.
id
.
toLowerCase
()]?.
reasonId
===
ExtensionRecommendationReason
.
Workspace
]
);
cksOverlay
.
push
([
'
isUserIgnoredRecommendation
'
,
extensionIgnoredRecommendationsService
.
globalIgnoredRecommendations
.
some
(
e
=>
e
===
extension
.
identifier
.
id
.
toLowerCase
())]
);
cksOverlay
.
push
([
'
inExtensionEditor
'
,
inExtensionEditor
]
);
if
(
extension
.
state
===
ExtensionState
.
Installed
)
{
scopedContextKeyService
.
createKey
<
string
>
(
'
extensionStatus
'
,
'
installed
'
);
cksOverlay
.
push
([
'
extensionStatus
'
,
'
installed
'
]
);
}
}
const
contextKeyService
=
accessor
.
get
(
IContextKeyService
).
createOverlay
(
cksOverlay
);
const
groups
:
IAction
[][]
=
[];
const
menu
=
menuService
.
createMenu
(
MenuId
.
ExtensionContext
,
scopedC
ontextKeyService
);
const
menu
=
menuService
.
createMenu
(
MenuId
.
ExtensionContext
,
c
ontextKeyService
);
menu
.
getActions
({
shouldForwardArgs
:
true
}).
forEach
(([,
actions
])
=>
groups
.
push
(
actions
.
map
(
action
=>
{
if
(
action
instanceof
SubmenuAction
)
{
return
action
;
...
...
@@ -885,7 +887,6 @@ export function getContextMenuActions(extension: IExtension | undefined | null,
return
instantiationService
.
createInstance
(
MenuItemExtensionAction
,
action
);
})));
menu
.
dispose
();
scopedContextKeyService
.
dispose
();
return
groups
;
});
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
浏览文件 @
82d255a3
...
...
@@ -463,7 +463,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
this
.
_body
.
classList
.
add
(
'
cell-list-container
'
);
this
.
_dndController
=
this
.
_register
(
new
CellDragAndDropController
(
this
,
this
.
_body
));
const
getScopedContextKeyService
=
(
container
?
:
HTMLElement
)
=>
this
.
_list
.
contextKeyService
.
createScoped
(
container
);
const
getScopedContextKeyService
=
(
container
:
HTMLElement
)
=>
this
.
_list
.
contextKeyService
.
createScoped
(
container
);
const
renderers
=
[
this
.
instantiationService
.
createInstance
(
CodeCellRenderer
,
this
,
this
.
_renderedEditors
,
this
.
_dndController
,
getScopedContextKeyService
),
this
.
instantiationService
.
createInstance
(
MarkdownCellRenderer
,
this
,
this
.
_dndController
,
this
.
_renderedEditors
,
getScopedContextKeyService
),
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
82d255a3
...
...
@@ -178,7 +178,7 @@ abstract class AbstractCellRenderer {
configurationService
:
IConfigurationService
,
private
readonly
keybindingService
:
IKeybindingService
,
private
readonly
notificationService
:
INotificationService
,
protected
readonly
contextKeyServiceProvider
:
(
container
?
:
HTMLElement
)
=>
IContextKeyService
,
protected
readonly
contextKeyServiceProvider
:
(
container
:
HTMLElement
)
=>
IContextKeyService
,
language
:
string
,
protected
readonly
dndController
:
CellDragAndDropController
)
{
...
...
@@ -375,7 +375,7 @@ export class MarkdownCellRenderer extends AbstractCellRenderer implements IListR
notebookEditor
:
INotebookEditor
,
dndController
:
CellDragAndDropController
,
private
renderedEditors
:
Map
<
ICellViewModel
,
ICodeEditor
|
undefined
>
,
contextKeyServiceProvider
:
(
container
?
:
HTMLElement
)
=>
IContextKeyService
,
contextKeyServiceProvider
:
(
container
:
HTMLElement
)
=>
IContextKeyService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
...
...
@@ -683,7 +683,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
protected
notebookEditor
:
INotebookEditor
,
private
renderedEditors
:
Map
<
ICellViewModel
,
ICodeEditor
|
undefined
>
,
dndController
:
CellDragAndDropController
,
contextKeyServiceProvider
:
(
container
?
:
HTMLElement
)
=>
IContextKeyService
,
contextKeyServiceProvider
:
(
container
:
HTMLElement
)
=>
IContextKeyService
,
@
IContextMenuService
contextMenuService
:
IContextMenuService
,
@
IConfigurationService
configurationService
:
IConfigurationService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
浏览文件 @
82d255a3
...
...
@@ -308,9 +308,10 @@ export class StatefulMarkdownCell extends Disposable {
this
.
templateData
.
editorContainer
.
innerText
=
''
;
// create a special context key service that set the inCompositeEditor-contextkey
const
editorContextKeyService
=
this
.
contextKeyService
.
createScoped
();
const
editorContextKeyService
=
this
.
contextKeyService
.
createOverlay
([
[
EditorContextKeys
.
inCompositeEditor
.
key
,
true
]
]);
const
editorInstaService
=
this
.
instantiationService
.
createChild
(
new
ServiceCollection
([
IContextKeyService
,
editorContextKeyService
]));
EditorContextKeys
.
inCompositeEditor
.
bindTo
(
editorContextKeyService
).
set
(
true
);
this
.
editor
=
editorInstaService
.
createInstance
(
CodeEditorWidget
,
this
.
templateData
.
editorContainer
,
{
...
this
.
editorOptions
,
...
...
src/vs/workbench/contrib/remote/browser/tunnelView.ts
浏览文件 @
82d255a3
...
...
@@ -271,10 +271,11 @@ class TunnelTreeRenderer extends Disposable implements ITreeRenderer<ITunnelGrou
templateData
.
iconLabel
.
setLabel
(
label
,
description
,
{
title
:
node
instanceof
TunnelItem
?
node
.
tooltip
:
tooltip
,
extraClasses
:
[
'
tunnel-view-label
'
]
});
templateData
.
actionBar
.
context
=
node
;
const
contextKeyService
=
this
.
_register
(
this
.
contextKeyService
.
createScoped
());
contextKeyService
.
createKey
(
'
view
'
,
this
.
viewId
);
contextKeyService
.
createKey
(
'
tunnelType
'
,
node
.
tunnelType
);
contextKeyService
.
createKey
(
'
tunnelCloseable
'
,
node
.
closeable
);
const
contextKeyService
=
this
.
contextKeyService
.
createOverlay
([
[
'
view
'
,
this
.
viewId
],
[
'
tunnelType
'
,
node
.
tunnelType
],
[
'
tunnelCloseable
'
,
node
.
closeable
],
]);
const
disposableStore
=
new
DisposableStore
();
templateData
.
elementDisposable
=
disposableStore
;
const
menu
=
disposableStore
.
add
(
this
.
menuService
.
createMenu
(
MenuId
.
TunnelInline
,
contextKeyService
));
...
...
@@ -295,7 +296,6 @@ class TunnelTreeRenderer extends Disposable implements ITreeRenderer<ITunnelGrou
}
menu
.
dispose
();
contextKeyService
.
dispose
();
}
private
renderInputBox
(
container
:
HTMLElement
,
editableData
:
IEditableData
):
IDisposable
{
...
...
@@ -609,10 +609,8 @@ export class TunnelPanel extends ViewPane {
this
.
tunnelViewSelectionContext
=
TunnelViewSelectionContextKey
.
bindTo
(
contextKeyService
);
this
.
portChangableContextKey
=
PortChangableContextKey
.
bindTo
(
contextKeyService
);
const
scopedContextKeyService
=
this
.
_register
(
this
.
contextKeyService
.
createScoped
());
scopedContextKeyService
.
createKey
(
'
view
'
,
TunnelPanel
.
ID
);
const
titleMenu
=
this
.
_register
(
this
.
menuService
.
createMenu
(
MenuId
.
TunnelTitle
,
scopedContextKeyService
));
const
overlayContextKeyService
=
this
.
_register
(
this
.
contextKeyService
.
createOverlay
([[
'
view
'
,
TunnelPanel
.
ID
]]));
const
titleMenu
=
this
.
_register
(
this
.
menuService
.
createMenu
(
MenuId
.
TunnelTitle
,
overlayContextKeyService
));
const
updateActions
=
()
=>
{
this
.
titleActions
=
[];
this
.
titleActionsDisposable
.
value
=
createAndFillInActionBarActions
(
titleMenu
,
undefined
,
this
.
titleActions
);
...
...
src/vs/workbench/contrib/scm/browser/dirtydiffDecorator.ts
浏览文件 @
82d255a3
...
...
@@ -169,7 +169,6 @@ class DirtyDiffWidget extends PeekViewWidget {
private
index
:
number
=
0
;
private
change
:
IChange
|
undefined
;
private
height
:
number
|
undefined
=
undefined
;
private
contextKeyService
:
IContextKeyService
;
constructor
(
editor
:
ICodeEditor
,
...
...
@@ -177,16 +176,17 @@ class DirtyDiffWidget extends PeekViewWidget {
@
IThemeService
private
readonly
themeService
:
IThemeService
,
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IMenuService
menuService
:
IMenuService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
@
IContextKeyService
_
contextKeyService
:
IContextKeyService
)
{
super
(
editor
,
{
isResizeable
:
true
,
frameWidth
:
1
,
keepEditorSelection
:
true
},
instantiationService
);
this
.
_disposables
.
add
(
themeService
.
onDidColorThemeChange
(
this
.
_applyTheme
,
this
));
this
.
_applyTheme
(
themeService
.
getColorTheme
());
this
.
contextKeyService
=
contextKeyService
.
createScoped
();
this
.
contextKeyService
.
createKey
(
'
originalResourceScheme
'
,
this
.
model
.
original
!
.
uri
.
scheme
);
this
.
menu
=
menuService
.
createMenu
(
MenuId
.
SCMChangeContext
,
this
.
contextKeyService
);
const
contextKeyService
=
_contextKeyService
.
createOverlay
([
[
'
originalResourceScheme
'
,
this
.
model
.
original
!
.
uri
.
scheme
]
]);
this
.
menu
=
menuService
.
createMenu
(
MenuId
.
SCMChangeContext
,
contextKeyService
);
this
.
create
();
if
(
editor
.
hasModel
())
{
...
...
src/vs/workbench/contrib/scm/browser/menus.ts
浏览文件 @
82d255a3
...
...
@@ -119,15 +119,12 @@ class SCMMenusItem implements IDisposable {
let
item
=
this
.
contextualResourceMenus
.
get
(
resource
.
contextValue
);
if
(
!
item
)
{
const
contextKeyService
=
this
.
contextKeyService
.
createScoped
();
contextKeyService
.
createKey
(
'
scmResourceState
'
,
resource
.
contextValue
);
const
contextKeyService
=
this
.
contextKeyService
.
createOverlay
([[
'
scmResourceState
'
,
resource
.
contextValue
]]);
const
menu
=
this
.
menuService
.
createMenu
(
MenuId
.
SCMResourceContext
,
contextKeyService
);
item
=
{
menu
,
dispose
()
{
menu
.
dispose
();
contextKeyService
.
dispose
();
}
};
...
...
@@ -148,7 +145,6 @@ class SCMMenusItem implements IDisposable {
}
this
.
resourceFolderMenu
?.
dispose
();
this
.
contextKeyService
.
dispose
();
}
}
...
...
@@ -178,10 +174,11 @@ export class SCMRepositoryMenus implements ISCMRepositoryMenus, IDisposable {
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IMenuService
private
readonly
menuService
:
IMenuService
)
{
this
.
contextKeyService
=
contextKeyService
.
createScoped
();
this
.
contextKeyService
.
createKey
<
string
|
undefined
>
(
'
scmProvider
'
,
provider
.
contextValue
);
this
.
contextKeyService
.
createKey
<
string
|
undefined
>
(
'
scmProviderRootUri
'
,
provider
.
rootUri
?.
toString
());
this
.
contextKeyService
.
createKey
<
boolean
>
(
'
scmProviderHasRootUri
'
,
!!
provider
.
rootUri
);
this
.
contextKeyService
=
contextKeyService
.
createOverlay
([
[
'
scmProvider
'
,
provider
.
contextValue
],
[
'
scmProviderRootUri
'
,
provider
.
rootUri
?.
toString
()],
[
'
scmProviderHasRootUri
'
,
!!
provider
.
rootUri
],
]);
const
serviceCollection
=
new
ServiceCollection
([
IContextKeyService
,
this
.
contextKeyService
]);
instantiationService
=
instantiationService
.
createChild
(
serviceCollection
);
...
...
@@ -207,9 +204,9 @@ export class SCMRepositoryMenus implements ISCMRepositoryMenus, IDisposable {
let
result
=
this
.
resourceGroupMenusItems
.
get
(
group
);
if
(
!
result
)
{
const
contextKeyService
=
this
.
contextKeyService
.
create
Scoped
();
contextKeyService
.
createKey
(
'
scmProvider
'
,
group
.
provider
.
contextValue
);
contextKeyService
.
createKey
(
'
scmResourceGroup
'
,
group
.
id
);
const
contextKeyService
=
this
.
contextKeyService
.
create
Overlay
([
[
'
scmResourceGroup
'
,
group
.
id
],
]
);
result
=
new
SCMMenusItem
(
contextKeyService
,
this
.
menuService
);
this
.
resourceGroupMenusItems
.
set
(
group
,
result
);
...
...
src/vs/workbench/contrib/timeline/browser/timelinePane.ts
浏览文件 @
82d255a3
...
...
@@ -1240,18 +1240,18 @@ class TimelinePaneCommands extends Disposable {
}
private
getActions
(
menuId
:
MenuId
,
context
:
{
key
:
string
,
value
?:
string
}):
{
primary
:
IAction
[];
secondary
:
IAction
[];
}
{
const
scoped
=
this
.
contextKeyService
.
createScoped
();
scoped
.
createKey
(
'
view
'
,
this
.
pane
.
id
);
scoped
.
createKey
(
context
.
key
,
context
.
value
);
const
contextKeyService
=
this
.
contextKeyService
.
createOverlay
([
[
'
view
'
,
this
.
pane
.
id
],
[
context
.
key
,
context
.
value
],
]);
const
menu
=
this
.
menuService
.
createMenu
(
menuId
,
scoped
);
const
menu
=
this
.
menuService
.
createMenu
(
menuId
,
contextKeyService
);
const
primary
:
IAction
[]
=
[];
const
secondary
:
IAction
[]
=
[];
const
result
=
{
primary
,
secondary
};
createAndFillInContextMenuActions
(
menu
,
{
shouldForwardArgs
:
true
},
result
,
g
=>
/^inline/
.
test
(
g
));
menu
.
dispose
();
scoped
.
dispose
();
return
result
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录