Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
09e120ac
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,发现更多精彩内容 >>
提交
09e120ac
编写于
6月 11, 2018
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #50256 - hook up cmd+f for new settings editor
上级
8994a584
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
152 addition
and
131 deletion
+152
-131
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
.../workbench/parts/preferences/browser/preferencesEditor.ts
+10
-126
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
...vs/workbench/parts/preferences/browser/settingsEditor2.ts
+25
-3
src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts
.../preferences/electron-browser/preferences.contribution.ts
+117
-2
未找到文件。
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
浏览文件 @
09e120ac
...
...
@@ -9,17 +9,17 @@ import { VSash } from 'vs/base/browser/ui/sash/sash';
import
{
Widget
}
from
'
vs/base/browser/ui/widget
'
;
import
*
as
arrays
from
'
vs/base/common/arrays
'
;
import
{
Delayer
,
ThrottledDelayer
}
from
'
vs/base/common/async
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IStringDictionary
}
from
'
vs/base/common/collections
'
;
import
{
getErrorMessage
,
isPromiseCanceledError
,
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
ArrayNavigator
}
from
'
vs/base/common/iterator
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
Disposable
,
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Command
,
EditorExtensionsRegistry
,
IEditorContributionCtor
,
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
EditorExtensionsRegistry
,
IEditorContributionCtor
,
registerEditorContribution
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
CodeEditorWidget
}
from
'
vs/editor/browser/widget/codeEditorWidget
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
...
...
@@ -30,9 +30,8 @@ import { MessageController } from 'vs/editor/contrib/message/messageController';
import
{
SelectionHighlighter
}
from
'
vs/editor/contrib/multicursor/multicursor
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
ConfigurationTarget
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
ContextKeyExpr
,
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingsRegistry
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
...
...
@@ -50,21 +49,20 @@ import { ResourceEditorModel } from 'vs/workbench/common/editor/resourceEditorMo
import
{
PREFERENCES_EDITOR_ID
}
from
'
vs/workbench/parts/files/common/files
'
;
import
{
DefaultSettingsRenderer
,
FolderSettingsRenderer
,
IPreferencesRenderer
,
UserSettingsRenderer
,
WorkspaceSettingsRenderer
}
from
'
vs/workbench/parts/preferences/browser/preferencesRenderers
'
;
import
{
SearchWidget
,
SettingsTarget
,
SettingsTargetsWidget
}
from
'
vs/workbench/parts/preferences/browser/preferencesWidgets
'
;
import
{
CONTEXT_SETTINGS_EDITOR
,
CONTEXT_SETTINGS_SEARCH_FOCUS
,
IPreferencesSearchService
,
ISearchProvider
,
SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS
,
SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING
,
SETTINGS_EDITOR_COMMAND_FOCUS_FILE
,
SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING
,
SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING
,
SETTINGS_EDITOR_COMMAND_SEARCH
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
CONTEXT_SETTINGS_EDITOR
,
CONTEXT_SETTINGS_SEARCH_FOCUS
,
IPreferencesSearchService
,
ISearchProvider
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IEditorGroup
,
IEditorGroupsService
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
import
{
IFilterResult
,
IPreferencesService
,
ISearchResult
,
ISetting
,
ISettingsEditorModel
,
ISettingsGroup
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
DefaultPreferencesEditorInput
,
PreferencesEditorInput
}
from
'
vs/workbench/services/preferences/common/preferencesEditorInput
'
;
import
{
DefaultSettingsEditorModel
,
SettingsEditorModel
}
from
'
vs/workbench/services/preferences/common/preferencesModels
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IEditorGroup
,
IEditorGroupsService
}
from
'
vs/workbench/services/group/common/editorGroupsService
'
;
export
class
PreferencesEditor
extends
BaseEditor
{
public
static
readonly
ID
:
string
=
PREFERENCES_EDITOR_ID
;
private
defaultSettingsEditorContextKey
:
IContextKey
<
boolean
>
;
private
focusSetting
sContextKey
:
IContextKey
<
boolean
>
;
private
searchFocu
sContextKey
:
IContextKey
<
boolean
>
;
private
headerContainer
:
HTMLElement
;
private
searchWidget
:
SearchWidget
;
private
sideBySidePreferencesWidget
:
SideBySidePreferencesWidget
;
...
...
@@ -88,7 +86,7 @@ export class PreferencesEditor extends BaseEditor {
)
{
super
(
PreferencesEditor
.
ID
,
telemetryService
,
themeService
);
this
.
defaultSettingsEditorContextKey
=
CONTEXT_SETTINGS_EDITOR
.
bindTo
(
this
.
contextKeyService
);
this
.
focusSetting
sContextKey
=
CONTEXT_SETTINGS_SEARCH_FOCUS
.
bindTo
(
this
.
contextKeyService
);
this
.
searchFocu
sContextKey
=
CONTEXT_SETTINGS_SEARCH_FOCUS
.
bindTo
(
this
.
contextKeyService
);
this
.
delayedFilterLogging
=
new
Delayer
<
void
>
(
1000
);
this
.
localSearchDelayer
=
new
Delayer
(
100
);
this
.
remoteSearchThrottle
=
new
ThrottledDelayer
(
200
);
...
...
@@ -115,7 +113,7 @@ export class PreferencesEditor extends BaseEditor {
this
.
searchWidget
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
SearchWidget
,
this
.
headerContainer
,
{
ariaLabel
:
nls
.
localize
(
'
SearchSettingsWidget.AriaLabel
'
,
"
Search settings
"
),
placeholder
:
nls
.
localize
(
'
SearchSettingsWidget.Placeholder
'
,
"
Search Settings
"
),
focusKey
:
this
.
focusSetting
sContextKey
,
focusKey
:
this
.
searchFocu
sContextKey
,
showResultCount
:
true
}));
this
.
_register
(
this
.
searchWidget
.
onDidChange
(
value
=>
this
.
onInputChanged
()));
...
...
@@ -1238,117 +1236,3 @@ class SettingsEditorContribution extends AbstractSettingsEditorContribution impl
}
registerEditorContribution
(
SettingsEditorContribution
);
abstract
class
SettingsCommand
extends
Command
{
protected
getPreferencesEditor
(
accessor
:
ServicesAccessor
):
PreferencesEditor
{
const
activeControl
=
accessor
.
get
(
IEditorService
).
activeControl
;
if
(
activeControl
instanceof
PreferencesEditor
)
{
return
activeControl
;
}
return
null
;
}
}
class
StartSearchDefaultSettingsCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
)
{
preferencesEditor
.
focusSearch
();
}
}
}
const
command
=
new
StartSearchDefaultSettingsCommand
({
id
:
SETTINGS_EDITOR_COMMAND_SEARCH
,
precondition
:
ContextKeyExpr
.
and
(
CONTEXT_SETTINGS_EDITOR
),
kbOpts
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_F
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
command
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
FocusSettingsFileEditorCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
)
{
preferencesEditor
.
focusSettingsFileEditor
();
}
}
}
const
focusSettingsFileEditorCommand
=
new
FocusSettingsFileEditorCommand
({
id
:
SETTINGS_EDITOR_COMMAND_FOCUS_FILE
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
DownArrow
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusSettingsFileEditorCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
ClearSearchResultsCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
)
{
preferencesEditor
.
clearSearchResults
();
}
}
}
const
clearSearchResultsCommand
=
new
ClearSearchResultsCommand
({
id
:
SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
Escape
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
clearSearchResultsCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
FocusNextSearchResultCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
)
{
preferencesEditor
.
focusNextResult
();
}
}
}
const
focusNextSearchResultCommand
=
new
FocusNextSearchResultCommand
({
id
:
SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
Enter
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusNextSearchResultCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
FocusPreviousSearchResultCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
)
{
preferencesEditor
.
focusPreviousResult
();
}
}
}
const
focusPreviousSearchResultCommand
=
new
FocusPreviousSearchResultCommand
({
id
:
SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyMod
.
Shift
|
KeyCode
.
Enter
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusPreviousSearchResultCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
EditFocusedSettingCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
)
{
preferencesEditor
.
editFocusedPreference
();
}
}
}
const
editFocusedSettingCommand
=
new
EditFocusedSettingCommand
({
id
:
SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
US_DOT
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
editFocusedSettingCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
src/vs/workbench/parts/preferences/browser/settingsEditor2.ts
浏览文件 @
09e120ac
...
...
@@ -27,12 +27,13 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import
{
EditorOptions
,
IEditor
}
from
'
vs/workbench/common/editor
'
;
import
{
SearchWidget
,
SettingsTarget
,
SettingsTargetsWidget
}
from
'
vs/workbench/parts/preferences/browser/preferencesWidgets
'
;
import
{
ISettingsEditorViewState
,
SearchResultIdx
,
SearchResultModel
,
SettingsAccessibilityProvider
,
SettingsDataSource
,
SettingsRenderer
,
SettingsTreeController
,
SettingsTreeFilter
,
TreeElement
}
from
'
vs/workbench/parts/preferences/browser/settingsTree
'
;
import
{
IPreferencesSearchService
,
ISearchProvider
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
IPreferencesSearchService
,
ISearchProvider
,
CONTEXT_SETTINGS_EDITOR
,
CONTEXT_SETTINGS_SEARCH_FOCUS
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
IPreferencesService
,
ISearchResult
,
ISettingsEditorModel
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
SettingsEditor2Input
}
from
'
vs/workbench/services/preferences/common/preferencesEditorInput
'
;
import
{
DefaultSettingsEditorModel
}
from
'
vs/workbench/services/preferences/common/preferencesModels
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IContextKey
,
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
const
$
=
DOM
.
$
;
...
...
@@ -65,6 +66,8 @@ export class SettingsEditor2 extends BaseEditor {
private
viewState
:
ISettingsEditorViewState
;
private
searchResultModel
:
SearchResultModel
;
private
inSettingsEditorContextKey
:
IContextKey
<
boolean
>
;
private
searchFocusContextKey
:
IContextKey
<
boolean
>
;
constructor
(
@
ITelemetryService
telemetryService
:
ITelemetryService
,
...
...
@@ -74,7 +77,8 @@ export class SettingsEditor2 extends BaseEditor {
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IPreferencesSearchService
private
preferencesSearchService
:
IPreferencesSearchService
,
@
ILogService
private
logService
:
ILogService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IContextKeyService
contextKeyService
:
IContextKeyService
)
{
super
(
SettingsEditor2
.
ID
,
telemetryService
,
themeService
);
this
.
delayedModifyLogging
=
new
Delayer
<
void
>
(
1000
);
...
...
@@ -83,6 +87,9 @@ export class SettingsEditor2 extends BaseEditor {
this
.
remoteSearchThrottle
=
new
ThrottledDelayer
(
200
);
this
.
viewState
=
{
settingsTarget
:
ConfigurationTarget
.
USER
};
this
.
inSettingsEditorContextKey
=
CONTEXT_SETTINGS_EDITOR
.
bindTo
(
contextKeyService
);
this
.
searchFocusContextKey
=
CONTEXT_SETTINGS_SEARCH_FOCUS
.
bindTo
(
contextKeyService
);
this
.
_register
(
configurationService
.
onDidChangeConfiguration
(()
=>
this
.
refreshTreeAndMaintainFocus
()));
}
...
...
@@ -94,21 +101,35 @@ export class SettingsEditor2 extends BaseEditor {
}
setInput
(
input
:
SettingsEditor2Input
,
options
:
EditorOptions
,
token
:
CancellationToken
):
Thenable
<
void
>
{
this
.
inSettingsEditorContextKey
.
set
(
true
);
return
super
.
setInput
(
input
,
options
,
token
)
.
then
(()
=>
{
this
.
render
(
token
);
});
}
clearInput
():
void
{
this
.
inSettingsEditorContextKey
.
set
(
false
);
super
.
clearInput
();
}
layout
(
dimension
:
DOM
.
Dimension
):
void
{
this
.
searchWidget
.
layout
(
dimension
);
this
.
layoutSettingsList
(
dimension
);
}
focus
():
void
{
this
.
focusSearch
();
}
focusSearch
():
void
{
this
.
searchWidget
.
focus
();
}
clearSearchResults
():
void
{
this
.
searchWidget
.
clear
();
}
private
createHeader
(
parent
:
HTMLElement
):
void
{
this
.
headerContainer
=
DOM
.
append
(
parent
,
$
(
'
.settings-header
'
));
...
...
@@ -123,7 +144,8 @@ export class SettingsEditor2 extends BaseEditor {
const
searchContainer
=
DOM
.
append
(
this
.
headerContainer
,
$
(
'
.search-container
'
));
this
.
searchWidget
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
SearchWidget
,
searchContainer
,
{
ariaLabel
:
localize
(
'
SearchSettings.AriaLabel
'
,
"
Search settings
"
),
placeholder
:
localize
(
'
SearchSettings.Placeholder
'
,
"
Search settings
"
)
placeholder
:
localize
(
'
SearchSettings.Placeholder
'
,
"
Search settings
"
),
focusKey
:
this
.
searchFocusContextKey
}));
this
.
_register
(
this
.
searchWidget
.
onDidChange
(()
=>
this
.
onSearchInputChanged
()));
this
.
_register
(
DOM
.
addStandardDisposableListener
(
this
.
searchWidget
.
domNode
,
'
keydown
'
,
e
=>
{
...
...
src/vs/workbench/parts/preferences/electron-browser/preferences.contribution.ts
浏览文件 @
09e120ac
...
...
@@ -22,7 +22,7 @@ import { KeybindingsEditor } from 'vs/workbench/parts/preferences/browser/keybin
import
{
OpenRawDefaultSettingsAction
,
OpenSettingsAction
,
OpenGlobalSettingsAction
,
OpenGlobalKeybindingsFileAction
,
OpenWorkspaceSettingsAction
,
OpenFolderSettingsAction
,
ConfigureLanguageBasedSettingsAction
,
OPEN_FOLDER_SETTINGS_COMMAND
,
OpenGlobalKeybindingsAction
,
OpenSettings2Action
}
from
'
vs/workbench/parts/preferences/browser/preferencesActions
'
;
import
{
IKeybindingsEditor
,
IPreferencesSearchService
,
CONTEXT_KEYBINDING_FOCUS
,
CONTEXT_KEYBINDINGS_EDITOR
,
CONTEXT_KEYBINDINGS_SEARCH_FOCUS
,
KEYBINDINGS_EDITOR_COMMAND_DEFINE
,
KEYBINDINGS_EDITOR_COMMAND_REMOVE
,
KEYBINDINGS_EDITOR_COMMAND_SEARCH
,
KEYBINDINGS_EDITOR_COMMAND_COPY
,
KEYBINDINGS_EDITOR_COMMAND_RESET
,
KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND
,
KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR
,
KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS
,
KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS
KEYBINDINGS_EDITOR_COMMAND_COPY
,
KEYBINDINGS_EDITOR_COMMAND_RESET
,
KEYBINDINGS_EDITOR_COMMAND_COPY_COMMAND
,
KEYBINDINGS_EDITOR_COMMAND_SHOW_SIMILAR
,
KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS
,
KEYBINDINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS
,
SETTINGS_EDITOR_COMMAND_SEARCH
,
CONTEXT_SETTINGS_EDITOR
,
SETTINGS_EDITOR_COMMAND_FOCUS_FILE
,
CONTEXT_SETTINGS_SEARCH_FOCUS
,
SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS
,
SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING
,
SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING
,
SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
...
...
@@ -34,6 +34,7 @@ import { IEditorRegistry, EditorDescriptor, Extensions as EditorExtensions } fro
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
PreferencesSearchService
}
from
'
vs/workbench/parts/preferences/electron-browser/preferencesSearch
'
;
import
{
IPreferencesService
}
from
'
vs/workbench/services/preferences/common/preferences
'
;
import
{
Command
}
from
'
vs/editor/browser/editorExtensions
'
;
registerSingleton
(
IPreferencesSearchService
,
PreferencesSearchService
);
...
...
@@ -323,4 +324,118 @@ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
title
:
`
${
category
}
:
${
OpenWorkspaceSettingsAction
.
LABEL
}
`
,
},
when
:
new
RawContextKey
<
string
>
(
'
workbenchState
'
,
''
).
notEqualsTo
(
'
empty
'
)
});
\ No newline at end of file
});
abstract
class
SettingsCommand
extends
Command
{
protected
getPreferencesEditor
(
accessor
:
ServicesAccessor
):
PreferencesEditor
|
SettingsEditor2
{
const
activeControl
=
accessor
.
get
(
IEditorService
).
activeControl
;
if
(
activeControl
instanceof
PreferencesEditor
||
activeControl
instanceof
SettingsEditor2
)
{
return
activeControl
;
}
return
null
;
}
}
class
StartSearchDefaultSettingsCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
)
{
preferencesEditor
.
focusSearch
();
}
}
}
const
startSearchCommand
=
new
StartSearchDefaultSettingsCommand
({
id
:
SETTINGS_EDITOR_COMMAND_SEARCH
,
precondition
:
ContextKeyExpr
.
and
(
CONTEXT_SETTINGS_EDITOR
),
kbOpts
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
KEY_F
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
startSearchCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
ClearSearchResultsCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
)
{
preferencesEditor
.
clearSearchResults
();
}
}
}
const
clearSearchResultsCommand
=
new
ClearSearchResultsCommand
({
id
:
SETTINGS_EDITOR_COMMAND_CLEAR_SEARCH_RESULTS
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
Escape
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
clearSearchResultsCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
FocusSettingsFileEditorCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
instanceof
PreferencesEditor
)
{
preferencesEditor
.
focusSettingsFileEditor
();
}
}
}
const
focusSettingsFileEditorCommand
=
new
FocusSettingsFileEditorCommand
({
id
:
SETTINGS_EDITOR_COMMAND_FOCUS_FILE
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
DownArrow
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusSettingsFileEditorCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
FocusNextSearchResultCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
instanceof
PreferencesEditor
)
{
preferencesEditor
.
focusNextResult
();
}
}
}
const
focusNextSearchResultCommand
=
new
FocusNextSearchResultCommand
({
id
:
SETTINGS_EDITOR_COMMAND_FOCUS_NEXT_SETTING
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyCode
.
Enter
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusNextSearchResultCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
FocusPreviousSearchResultCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
instanceof
PreferencesEditor
)
{
preferencesEditor
.
focusPreviousResult
();
}
}
}
const
focusPreviousSearchResultCommand
=
new
FocusPreviousSearchResultCommand
({
id
:
SETTINGS_EDITOR_COMMAND_FOCUS_PREVIOUS_SETTING
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyMod
.
Shift
|
KeyCode
.
Enter
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
focusPreviousSearchResultCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
class
EditFocusedSettingCommand
extends
SettingsCommand
{
public
runCommand
(
accessor
:
ServicesAccessor
,
args
:
any
):
void
{
const
preferencesEditor
=
this
.
getPreferencesEditor
(
accessor
);
if
(
preferencesEditor
instanceof
PreferencesEditor
)
{
preferencesEditor
.
editFocusedPreference
();
}
}
}
const
editFocusedSettingCommand
=
new
EditFocusedSettingCommand
({
id
:
SETTINGS_EDITOR_COMMAND_EDIT_FOCUSED_SETTING
,
precondition
:
CONTEXT_SETTINGS_SEARCH_FOCUS
,
kbOpts
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyCode
.
US_DOT
}
});
KeybindingsRegistry
.
registerCommandAndKeybindingRule
(
editFocusedSettingCommand
.
toCommandAndKeybindingRule
(
KeybindingsRegistry
.
WEIGHT
.
editorContrib
()));
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录