Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
f0f2c909
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,发现更多精彩内容 >>
提交
f0f2c909
编写于
10月 13, 2017
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Open full settings editor when clicking on settings.json in explorer (fixes #35579)
上级
3a4ee7e2
变更
10
隐藏空白更改
内联
并排
Showing
10 changed file
with
267 addition
and
64 deletion
+267
-64
src/vs/workbench/browser/parts/editor/editorPart.ts
src/vs/workbench/browser/parts/editor/editorPart.ts
+36
-21
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+38
-1
src/vs/workbench/parts/preferences/browser/preferences.contribution.ts
...nch/parts/preferences/browser/preferences.contribution.ts
+2
-2
src/vs/workbench/parts/preferences/browser/preferencesService.ts
...workbench/parts/preferences/browser/preferencesService.ts
+13
-23
src/vs/workbench/parts/preferences/common/preferences.ts
src/vs/workbench/parts/preferences/common/preferences.ts
+9
-5
src/vs/workbench/parts/preferences/common/preferencesContribution.ts
...bench/parts/preferences/common/preferencesContribution.ts
+148
-0
src/vs/workbench/services/editor/browser/editorService.ts
src/vs/workbench/services/editor/browser/editorService.ts
+8
-9
src/vs/workbench/services/group/common/groupService.ts
src/vs/workbench/services/group/common/groupService.ts
+6
-1
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
...workbench/services/textfile/common/textFileEditorModel.ts
+0
-1
src/vs/workbench/test/workbenchTestServices.ts
src/vs/workbench/test/workbenchTestServices.ts
+7
-1
未找到文件。
src/vs/workbench/browser/parts/editor/editorPart.ts
浏览文件 @
f0f2c909
...
...
@@ -21,14 +21,14 @@ import { toErrorMessage } from 'vs/base/common/errorMessage';
import
{
Scope
as
MementoScope
}
from
'
vs/workbench/common/memento
'
;
import
{
Part
}
from
'
vs/workbench/browser/part
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
EditorInput
,
EditorOptions
,
ConfirmResult
,
IWorkbenchEditorConfiguration
,
TextEditorOptions
,
SideBySideEditorInput
,
TextCompareEditorVisible
,
TEXT_DIFF_EDITOR_ID
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorInput
,
EditorOptions
,
ConfirmResult
,
IWorkbenchEditorConfiguration
,
TextEditorOptions
,
SideBySideEditorInput
,
TextCompareEditorVisible
,
TEXT_DIFF_EDITOR_ID
,
EditorOpeningEvent
,
IEditorOpeningEvent
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorGroupsControl
,
Rochade
,
IEditorGroupsControl
,
ProgressState
}
from
'
vs/workbench/browser/parts/editor/editorGroupsControl
'
;
import
{
WorkbenchProgressService
}
from
'
vs/workbench/services/progress/browser/progressService
'
;
import
{
IEditorGroupService
,
GroupOrientation
,
GroupArrangement
,
IEditorTabOptions
,
IMoveOptions
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IEditorPart
}
from
'
vs/workbench/services/editor/browser/editorService
'
;
import
{
IPartService
}
from
'
vs/workbench/services/part/common/partService
'
;
import
{
Position
,
POSITIONS
,
Direction
}
from
'
vs/platform/editor/common/editor
'
;
import
{
Position
,
POSITIONS
,
Direction
,
IEditor
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IStorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
...
...
@@ -99,6 +99,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
private
revealIfOpen
:
boolean
;
private
_onEditorsChanged
:
Emitter
<
void
>
;
private
_onEditorOpening
:
Emitter
<
IEditorOpeningEvent
>
;
private
_onEditorsMoved
:
Emitter
<
void
>
;
private
_onEditorOpenFail
:
Emitter
<
EditorInput
>
;
private
_onGroupOrientationChanged
:
Emitter
<
void
>
;
...
...
@@ -132,6 +133,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
super
(
id
,
{
hasTitle
:
false
},
themeService
);
this
.
_onEditorsChanged
=
new
Emitter
<
void
>
();
this
.
_onEditorOpening
=
new
Emitter
<
IEditorOpeningEvent
>
();
this
.
_onEditorsMoved
=
new
Emitter
<
void
>
();
this
.
_onEditorOpenFail
=
new
Emitter
<
EditorInput
>
();
this
.
_onGroupOrientationChanged
=
new
Emitter
<
void
>
();
...
...
@@ -289,6 +291,10 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return
this
.
_onEditorsChanged
.
event
;
}
public
get
onEditorOpening
():
Event
<
IEditorOpeningEvent
>
{
return
this
.
_onEditorOpening
.
event
;
}
public
get
onEditorsMoved
():
Event
<
void
>
{
return
this
.
_onEditorsMoved
.
event
;
}
...
...
@@ -309,12 +315,12 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return
this
.
tabOptions
;
}
public
openEditor
(
input
:
EditorInput
,
options
?:
EditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
Base
Editor
>
;
public
openEditor
(
input
:
EditorInput
,
options
?:
EditorOptions
,
position
?:
Position
,
ratio
?:
number
[]):
TPromise
<
Base
Editor
>
;
public
openEditor
(
input
:
EditorInput
,
options
?:
EditorOptions
,
arg3
?:
any
,
ratio
?:
number
[]):
TPromise
<
Base
Editor
>
{
// Normalize some values
if
(
!
options
)
{
options
=
null
;
}
public
openEditor
(
input
:
EditorInput
,
options
?:
EditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
I
Editor
>
;
public
openEditor
(
input
:
EditorInput
,
options
?:
EditorOptions
,
position
?:
Position
,
ratio
?:
number
[]):
TPromise
<
I
Editor
>
;
public
openEditor
(
input
:
EditorInput
,
options
?:
EditorOptions
,
arg3
?:
any
,
ratio
?:
number
[]):
TPromise
<
I
Editor
>
{
if
(
!
options
)
{
options
=
null
;
}
// Determine position to open editor in (one, two, three)
const
position
=
this
.
findPosition
(
input
,
options
,
arg3
,
ratio
);
...
...
@@ -329,6 +335,20 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return
TPromise
.
as
<
BaseEditor
>
(
null
);
}
// Editor opening event (can be prevented and overridden)
const
event
=
new
EditorOpeningEvent
(
input
,
position
);
this
.
_onEditorOpening
.
fire
(
event
);
const
prevented
=
event
.
isPrevented
();
if
(
prevented
)
{
return
prevented
();
}
// Open through UI
return
this
.
doOpenEditor
(
position
,
input
,
options
,
ratio
);
}
private
doOpenEditor
(
position
:
Position
,
input
:
EditorInput
,
options
:
EditorOptions
,
ratio
:
number
[]):
TPromise
<
BaseEditor
>
{
// We need an editor descriptor for the input
const
descriptor
=
Registry
.
as
<
IEditorRegistry
>
(
EditorExtensions
.
Editors
).
getEditor
(
input
);
if
(
!
descriptor
)
{
...
...
@@ -345,12 +365,6 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
this
.
telemetryService
.
publicLog
(
'
workbenchSideEditorOpened
'
,
{
position
:
position
});
}
// Open through UI
return
this
.
doOpenEditor
(
position
,
descriptor
,
input
,
options
,
ratio
);
}
private
doOpenEditor
(
position
:
Position
,
descriptor
:
IEditorDescriptor
,
input
:
EditorInput
,
options
:
EditorOptions
,
ratio
:
number
[]):
TPromise
<
BaseEditor
>
{
// Update stacks: We do this early on before the UI is there because we want our stacks model to have
// a consistent view of the editor world and updating it later async after the UI is there will cause
// issues (e.g. when a closeEditor call is made that expects the openEditor call to have updated the
...
...
@@ -1007,7 +1021,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
}
}
public
replaceEditors
(
editors
:
{
toReplace
:
EditorInput
,
replaceWith
:
EditorInput
,
options
?:
EditorOptions
}[],
position
?:
Position
):
TPromise
<
Base
Editor
[]
>
{
public
replaceEditors
(
editors
:
{
toReplace
:
EditorInput
,
replaceWith
:
EditorInput
,
options
?:
EditorOptions
}[],
position
?:
Position
):
TPromise
<
I
Editor
[]
>
{
const
activeReplacements
:
IEditorReplacement
[]
=
[];
const
hiddenReplacements
:
IEditorReplacement
[]
=
[];
...
...
@@ -1066,9 +1080,9 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return
res
;
}
public
openEditors
(
editors
:
{
input
:
EditorInput
,
position
:
Position
,
options
?:
EditorOptions
}[]):
TPromise
<
Base
Editor
[]
>
{
public
openEditors
(
editors
:
{
input
:
EditorInput
,
position
:
Position
,
options
?:
EditorOptions
}[]):
TPromise
<
I
Editor
[]
>
{
if
(
!
editors
.
length
)
{
return
TPromise
.
as
<
Base
Editor
[]
>
([]);
return
TPromise
.
as
<
I
Editor
[]
>
([]);
}
let
activePosition
:
Position
;
...
...
@@ -1085,7 +1099,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return
this
.
stacks
.
groups
.
some
(
g
=>
g
.
count
>
0
);
}
public
restoreEditors
():
TPromise
<
Base
Editor
[]
>
{
public
restoreEditors
():
TPromise
<
I
Editor
[]
>
{
const
editors
=
this
.
stacks
.
groups
.
map
((
group
,
index
)
=>
{
return
{
input
:
group
.
activeEditor
,
...
...
@@ -1095,7 +1109,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
});
if
(
!
editors
.
length
)
{
return
TPromise
.
as
<
Base
Editor
[]
>
([]);
return
TPromise
.
as
<
I
Editor
[]
>
([]);
}
let
activePosition
:
Position
;
...
...
@@ -1108,7 +1122,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
return
this
.
doOpenEditors
(
editors
,
activePosition
,
editorState
&&
editorState
.
ratio
);
}
private
doOpenEditors
(
editors
:
{
input
:
EditorInput
,
position
:
Position
,
options
?:
EditorOptions
}[],
activePosition
?:
number
,
ratio
?:
number
[]):
TPromise
<
Base
Editor
[]
>
{
private
doOpenEditors
(
editors
:
{
input
:
EditorInput
,
position
:
Position
,
options
?:
EditorOptions
}[],
activePosition
?:
number
,
ratio
?:
number
[]):
TPromise
<
I
Editor
[]
>
{
const
positionOneEditors
=
editors
.
filter
(
e
=>
e
.
position
===
Position
.
ONE
);
const
positionTwoEditors
=
editors
.
filter
(
e
=>
e
.
position
===
Position
.
TWO
);
const
positionThreeEditors
=
editors
.
filter
(
e
=>
e
.
position
===
Position
.
THREE
);
...
...
@@ -1155,7 +1169,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Open each input respecting the options. Since there can only be one active editor in each
// position, we have to pick the first input from each position and add the others as inactive
const
promises
:
TPromise
<
Base
Editor
>
[]
=
[];
const
promises
:
TPromise
<
I
Editor
>
[]
=
[];
[
positionOneEditors
.
shift
(),
positionTwoEditors
.
shift
(),
positionThreeEditors
.
shift
()].
forEach
((
editor
,
position
)
=>
{
if
(
!
editor
)
{
return
;
// unused position
...
...
@@ -1343,6 +1357,7 @@ export class EditorPart extends Part implements IEditorPart, IEditorGroupService
// Emitters
this
.
_onEditorsChanged
.
dispose
();
this
.
_onEditorOpening
.
dispose
();
this
.
_onEditorsMoved
.
dispose
();
this
.
_onEditorOpenFail
.
dispose
();
...
...
src/vs/workbench/common/editor.ts
浏览文件 @
f0f2c909
...
...
@@ -11,7 +11,7 @@ import types = require('vs/base/common/types');
import
URI
from
'
vs/base/common/uri
'
;
import
{
IDisposable
,
dispose
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IEditor
,
IEditorViewState
,
IModel
,
ScrollType
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorInput
,
IEditorModel
,
IEditorOptions
,
ITextEditorOptions
,
IBaseResourceInput
,
Position
,
Verbosity
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorInput
,
IEditorModel
,
IEditorOptions
,
ITextEditorOptions
,
IBaseResourceInput
,
Position
,
Verbosity
,
IEditor
as
IBaseEditor
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IInstantiationService
,
IConstructorSignature0
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
...
...
@@ -260,6 +260,43 @@ export abstract class EditorInput implements IEditorInput {
}
}
export
interface
IEditorOpeningEvent
{
input
:
IEditorInput
;
position
:
Position
;
/**
* Allows to prevent the opening of an editor by providing a callback
* that will be executed instead. By returning another editor promise
* it is possible to override the opening with another editor. It is ok
* to return a promise that resolves to NULL to prevent the opening
* altogether.
*/
prevent
(
callback
:
()
=>
TPromise
<
IBaseEditor
>
):
void
;
}
export
class
EditorOpeningEvent
{
private
override
:
()
=>
TPromise
<
IBaseEditor
>
;
constructor
(
private
_editorInput
:
IEditorInput
,
private
_position
:
Position
)
{
}
public
get
input
():
IEditorInput
{
return
this
.
_editorInput
;
}
public
get
position
():
Position
{
return
this
.
_position
;
}
public
prevent
(
callback
:
()
=>
TPromise
<
IBaseEditor
>
):
void
{
this
.
override
=
callback
;
}
public
isPrevented
():
()
=>
TPromise
<
IBaseEditor
>
{
return
this
.
override
;
}
}
export
enum
EncodingMode
{
/**
...
...
src/vs/workbench/parts/preferences/browser/preferences.contribution.ts
浏览文件 @
f0f2c909
...
...
@@ -24,7 +24,7 @@ import {
import
{
PreferencesService
}
from
'
vs/workbench/parts/preferences/browser/preferencesService
'
;
import
{
IInstantiationService
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
PreferencesCont
entProvider
}
from
'
vs/workbench/parts/preferences/common/preferencesContentProvider
'
;
import
{
PreferencesCont
ribution
}
from
'
vs/workbench/parts/preferences/common/preferencesContribution
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IWorkbenchEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
...
...
@@ -257,7 +257,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
}
});
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
).
registerWorkbenchContribution
(
PreferencesCont
entProvider
);
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
).
registerWorkbenchContribution
(
PreferencesCont
ribution
);
CommandsRegistry
.
registerCommand
(
OPEN_FOLDER_SETTINGS_COMMAND
,
function
(
accessor
:
ServicesAccessor
,
args
?:
IWorkspaceFolder
)
{
const
preferencesService
=
accessor
.
get
(
IPreferencesService
);
...
...
src/vs/workbench/parts/preferences/browser/preferencesService.ts
浏览文件 @
f0f2c909
...
...
@@ -8,7 +8,6 @@ import * as network from 'vs/base/common/network';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
{
ResourceMap
}
from
'
vs/base/common/map
'
;
import
*
as
labels
from
'
vs/base/common/labels
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
...
...
@@ -28,7 +27,7 @@ import { IExtensionService } from 'vs/platform/extensions/common/extensions';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IConfigurationEditingService
,
ConfigurationTarget
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
IPreferencesService
,
IPreferencesEditorModel
,
ISetting
,
getSettingsTargetName
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
IPreferencesService
,
IPreferencesEditorModel
,
ISetting
,
getSettingsTargetName
,
FOLDER_SETTINGS_PATH
,
DEFAULT_SETTINGS_EDITOR_SETTING
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
SettingsEditorModel
,
DefaultSettingsEditorModel
,
DefaultKeybindingsEditorModel
,
defaultKeybindingsContents
,
WorkspaceConfigModel
}
from
'
vs/workbench/parts/preferences/common/preferencesModels
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
DefaultPreferencesEditorInput
,
PreferencesEditorInput
}
from
'
vs/workbench/parts/preferences/browser/preferencesEditor
'
;
...
...
@@ -42,15 +41,6 @@ import { IModelService } from 'vs/editor/common/services/modelService';
import
{
IJSONEditingService
}
from
'
vs/workbench/services/configuration/common/jsonEditing
'
;
import
{
ConfigurationScope
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
interface
IWorkbenchSettingsConfiguration
{
workbench
:
{
settings
:
{
openDefaultSettings
:
boolean
;
}
};
}
const
emptyEditableSettingsContent
=
'
{
\n
}
'
;
export
class
PreferencesService
extends
Disposable
implements
IPreferencesService
{
...
...
@@ -186,20 +176,20 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return
TPromise
.
wrap
<
IPreferencesEditorModel
<
any
>>
(
null
);
}
openGlobalSettings
():
TPromise
<
IEditor
>
{
return
this
.
doOpenSettings
(
ConfigurationTarget
.
USER
,
this
.
userSettingsResource
);
openGlobalSettings
(
position
?:
EditorPosition
):
TPromise
<
IEditor
>
{
return
this
.
doOpenSettings
(
ConfigurationTarget
.
USER
,
this
.
userSettingsResource
,
position
);
}
openWorkspaceSettings
():
TPromise
<
IEditor
>
{
openWorkspaceSettings
(
position
?:
EditorPosition
):
TPromise
<
IEditor
>
{
if
(
this
.
contextService
.
getWorkbenchState
()
===
WorkbenchState
.
EMPTY
)
{
this
.
messageService
.
show
(
Severity
.
Info
,
nls
.
localize
(
'
openFolderFirst
'
,
"
Open a folder first to create workspace settings
"
));
return
TPromise
.
as
(
null
);
}
return
this
.
doOpenSettings
(
ConfigurationTarget
.
WORKSPACE
,
this
.
workspaceSettingsResource
);
return
this
.
doOpenSettings
(
ConfigurationTarget
.
WORKSPACE
,
this
.
workspaceSettingsResource
,
position
);
}
openFolderSettings
(
folder
:
URI
):
TPromise
<
IEditor
>
{
return
this
.
doOpenSettings
(
ConfigurationTarget
.
FOLDER
,
this
.
getEditableSettingsURI
(
ConfigurationTarget
.
FOLDER
,
folder
));
openFolderSettings
(
folder
:
URI
,
position
?:
EditorPosition
):
TPromise
<
IEditor
>
{
return
this
.
doOpenSettings
(
ConfigurationTarget
.
FOLDER
,
this
.
getEditableSettingsURI
(
ConfigurationTarget
.
FOLDER
,
folder
)
,
position
);
}
switchSettings
(
target
:
ConfigurationTarget
,
resource
:
URI
):
TPromise
<
void
>
{
...
...
@@ -259,17 +249,17 @@ export class PreferencesService extends Disposable implements IPreferencesServic
});
}
private
doOpenSettings
(
configurationTarget
:
ConfigurationTarget
,
resource
:
URI
):
TPromise
<
IEditor
>
{
const
openDefaultSettings
=
!!
this
.
configurationService
.
getConfiguration
<
IWorkbenchSettingsConfiguration
>
().
workbench
.
settings
.
openDefaultSettings
;
private
doOpenSettings
(
configurationTarget
:
ConfigurationTarget
,
resource
:
URI
,
position
?:
EditorPosition
):
TPromise
<
IEditor
>
{
const
openDefaultSettings
=
!!
this
.
configurationService
.
lookup
(
DEFAULT_SETTINGS_EDITOR_SETTING
).
value
;
return
this
.
getOrCreateEditableSettingsEditorInput
(
configurationTarget
,
resource
)
.
then
(
editableSettingsEditorInput
=>
{
if
(
openDefaultSettings
)
{
const
defaultPreferencesEditorInput
=
this
.
instantiationService
.
createInstance
(
DefaultPreferencesEditorInput
,
this
.
getDefaultSettingsResource
(
configurationTarget
));
const
preferencesEditorInput
=
new
PreferencesEditorInput
(
this
.
getPreferencesEditorInputName
(
configurationTarget
,
resource
),
editableSettingsEditorInput
.
getDescription
(),
defaultPreferencesEditorInput
,
<
EditorInput
>
editableSettingsEditorInput
);
this
.
lastOpenedSettingsInput
=
preferencesEditorInput
;
return
this
.
editorService
.
openEditor
(
preferencesEditorInput
,
{
pinned
:
true
});
return
this
.
editorService
.
openEditor
(
preferencesEditorInput
,
{
pinned
:
true
}
,
position
);
}
return
this
.
editorService
.
openEditor
(
editableSettingsEditorInput
,
{
pinned
:
true
});
return
this
.
editorService
.
openEditor
(
editableSettingsEditorInput
,
{
pinned
:
true
}
,
position
);
});
}
...
...
@@ -325,10 +315,10 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return
null
;
}
const
workspace
=
this
.
contextService
.
getWorkspace
();
return
workspace
.
configuration
||
workspace
.
folders
[
0
].
toResource
(
paths
.
join
(
'
.vscode
'
,
'
settings.json
'
)
);
return
workspace
.
configuration
||
workspace
.
folders
[
0
].
toResource
(
FOLDER_SETTINGS_PATH
);
case
ConfigurationTarget
.
FOLDER
:
const
folder
=
this
.
contextService
.
getWorkspaceFolder
(
resource
);
return
folder
?
folder
.
toResource
(
paths
.
join
(
'
.vscode
'
,
'
settings.json
'
)
)
:
null
;
return
folder
?
folder
.
toResource
(
FOLDER_SETTINGS_PATH
)
:
null
;
}
return
null
;
}
...
...
src/vs/workbench/parts/preferences/common/preferences.ts
浏览文件 @
f0f2c909
...
...
@@ -8,11 +8,12 @@ import URI from 'vs/base/common/uri';
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IEditor
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditor
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IKeybindingItemEntry
}
from
'
vs/workbench/parts/preferences/common/keybindingsEditorModel
'
;
import
{
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
ConfigurationTarget
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
join
}
from
'
vs/base/common/paths
'
;
export
interface
ISettingsGroup
{
id
:
string
;
...
...
@@ -76,9 +77,9 @@ export interface IPreferencesService {
resolveContent
(
uri
:
URI
):
TPromise
<
string
>
;
createPreferencesEditorModel
<
T
>
(
uri
:
URI
):
TPromise
<
IPreferencesEditorModel
<
T
>>
;
openGlobalSettings
():
TPromise
<
IEditor
>
;
openWorkspaceSettings
():
TPromise
<
IEditor
>
;
openFolderSettings
(
folder
:
URI
):
TPromise
<
IEditor
>
;
openGlobalSettings
(
position
?:
Position
):
TPromise
<
IEditor
>
;
openWorkspaceSettings
(
position
?:
Position
):
TPromise
<
IEditor
>
;
openFolderSettings
(
folder
:
URI
,
position
?:
Position
):
TPromise
<
IEditor
>
;
switchSettings
(
target
:
ConfigurationTarget
,
resource
:
URI
):
TPromise
<
void
>
;
openGlobalKeybindingSettings
(
textual
:
boolean
):
TPromise
<
void
>
;
...
...
@@ -130,4 +131,7 @@ export const KEYBINDINGS_EDITOR_COMMAND_REMOVE = 'keybindings.editor.removeKeybi
export
const
KEYBINDINGS_EDITOR_COMMAND_RESET
=
'
keybindings.editor.resetKeybinding
'
;
export
const
KEYBINDINGS_EDITOR_COMMAND_COPY
=
'
keybindings.editor.copyKeybindingEntry
'
;
export
const
KEYBINDINGS_EDITOR_COMMAND_SHOW_CONFLICTS
=
'
keybindings.editor.showConflicts
'
;
export
const
KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS
=
'
keybindings.editor.focusKeybindings
'
;
\ No newline at end of file
export
const
KEYBINDINGS_EDITOR_COMMAND_FOCUS_KEYBINDINGS
=
'
keybindings.editor.focusKeybindings
'
;
export
const
FOLDER_SETTINGS_PATH
=
join
(
'
.vscode
'
,
'
settings.json
'
);
export
const
DEFAULT_SETTINGS_EDITOR_SETTING
=
'
workbench.settings.openDefaultSettings
'
;
\ No newline at end of file
src/vs/workbench/parts/preferences/common/preferencesCont
entProvider
.ts
→
src/vs/workbench/parts/preferences/common/preferencesCont
ribution
.ts
浏览文件 @
f0f2c909
...
...
@@ -13,22 +13,83 @@ import JSONContributionRegistry = require('vs/platform/jsonschemas/common/jsonCo
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
IPreferencesService
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IPreferencesService
,
FOLDER_SETTINGS_PATH
,
DEFAULT_SETTINGS_EDITOR_SETTING
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IEditorGroupService
}
from
'
vs/workbench/services/group/common/groupService
'
;
import
{
endsWith
}
from
'
vs/base/common/strings
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
import
{
IEditorOpeningEvent
}
from
'
vs/workbench/common/editor
'
;
import
{
IWorkspaceContextService
,
WorkbenchState
}
from
'
vs/platform/workspace/common/workspace
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
const
schemaRegistry
=
Registry
.
as
<
JSONContributionRegistry
.
IJSONContributionRegistry
>
(
JSONContributionRegistry
.
Extensions
.
JSONContribution
);
export
class
PreferencesContentProvider
implements
IWorkbenchContribution
{
export
class
PreferencesContribution
implements
IWorkbenchContribution
{
private
editorOpeningListener
:
IDisposable
;
private
settingsListener
:
IDisposable
;
constructor
(
@
IModelService
private
modelService
:
IModelService
,
@
ITextModelService
private
textModelResolverService
:
ITextModelService
,
@
IPreferencesService
private
preferencesService
:
IPreferencesService
,
@
IModeService
private
modeService
:
IModeService
@
IModeService
private
modeService
:
IModeService
,
@
IEditorGroupService
private
editorGroupService
:
IEditorGroupService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
,
@
IWorkspaceContextService
private
workspaceService
:
IWorkspaceContextService
,
@
IConfigurationService
private
configurationService
:
IConfigurationService
)
{
this
.
settingsListener
=
this
.
configurationService
.
onDidUpdateConfiguration
(()
=>
this
.
handleSettingsEditorOverride
());
this
.
handleSettingsEditorOverride
();
this
.
start
();
}
private
handleSettingsEditorOverride
():
void
{
// dispose any old listener we had
this
.
editorOpeningListener
=
dispose
(
this
.
editorOpeningListener
);
// install editor opening listener unless user has disabled this
if
(
!!
this
.
configurationService
.
lookup
(
DEFAULT_SETTINGS_EDITOR_SETTING
).
value
)
{
this
.
editorOpeningListener
=
this
.
editorGroupService
.
onEditorOpening
(
e
=>
this
.
onEditorOpening
(
e
));
}
}
private
onEditorOpening
(
event
:
IEditorOpeningEvent
):
void
{
const
resource
=
event
.
input
.
getResource
();
if
(
!
resource
||
resource
.
scheme
!==
'
file
'
||
// require a file path opening
!
endsWith
(
resource
.
fsPath
,
'
settings.json
'
)
||
// file must end in settings.json
!
this
.
configurationService
.
lookup
(
DEFAULT_SETTINGS_EDITOR_SETTING
).
value
// user has not disabled default settings editor
)
{
return
;
}
// Global User Settings File
if
(
resource
.
fsPath
===
this
.
environmentService
.
appSettingsPath
)
{
return
event
.
prevent
(()
=>
this
.
preferencesService
.
openGlobalSettings
(
event
.
position
));
}
// Single Folder Workspace Settings File
const
state
=
this
.
workspaceService
.
getWorkbenchState
();
if
(
state
===
WorkbenchState
.
FOLDER
)
{
const
folders
=
this
.
workspaceService
.
getWorkspace
().
folders
;
if
(
resource
.
fsPath
===
folders
[
0
].
toResource
(
FOLDER_SETTINGS_PATH
).
fsPath
)
{
return
event
.
prevent
(()
=>
this
.
preferencesService
.
openWorkspaceSettings
(
event
.
position
));
}
}
// Multi Folder Workspace Settings File
else
if
(
state
===
WorkbenchState
.
WORKSPACE
)
{
const
folders
=
this
.
workspaceService
.
getWorkspace
().
folders
;
for
(
let
i
=
0
;
i
<
folders
.
length
;
i
++
)
{
if
(
resource
.
fsPath
===
folders
[
i
].
toResource
(
FOLDER_SETTINGS_PATH
).
fsPath
)
{
return
event
.
prevent
(()
=>
this
.
preferencesService
.
openFolderSettings
(
folders
[
i
].
uri
,
event
.
position
));
}
}
}
}
public
getId
():
string
{
return
'
vs.contentprovider
'
;
}
...
...
@@ -79,4 +140,9 @@ export class PreferencesContentProvider implements IWorkbenchContribution {
}
return
null
;
}
public
dispose
():
void
{
this
.
editorOpeningListener
=
dispose
(
this
.
editorOpeningListener
);
this
.
settingsListener
=
dispose
(
this
.
settingsListener
);
}
}
src/vs/workbench/services/editor/browser/editorService.ts
浏览文件 @
f0f2c909
...
...
@@ -9,7 +9,6 @@ import URI from 'vs/base/common/uri';
import
network
=
require
(
'
vs/base/common/network
'
);
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
basename
,
dirname
}
from
'
vs/base/common/paths
'
;
import
{
BaseEditor
}
from
'
vs/workbench/browser/parts/editor/baseEditor
'
;
import
{
EditorInput
,
EditorOptions
,
TextEditorOptions
,
Extensions
as
EditorExtensions
,
SideBySideEditorInput
,
IFileEditorInput
,
IFileInputFactory
,
IEditorInputFactoryRegistry
}
from
'
vs/workbench/common/editor
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
import
{
IUntitledEditorService
,
UNTITLED_SCHEMA
}
from
'
vs/workbench/services/untitled/common/untitledEditorService
'
;
...
...
@@ -26,14 +25,14 @@ import { IEnvironmentService } from 'vs/platform/environment/common/environment'
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
export
interface
IEditorPart
{
openEditor
(
input
?:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
Base
Editor
>
;
openEditor
(
input
?:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
position
?:
Position
):
TPromise
<
Base
Editor
>
;
openEditors
(
editors
:
{
input
:
IEditorInput
,
position
:
Position
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[]):
TPromise
<
Base
Editor
[]
>
;
replaceEditors
(
editors
:
{
toReplace
:
IEditorInput
,
replaceWith
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[],
position
?:
Position
):
TPromise
<
Base
Editor
[]
>
;
openEditor
(
input
?:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
I
Editor
>
;
openEditor
(
input
?:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
,
position
?:
Position
):
TPromise
<
I
Editor
>
;
openEditors
(
editors
:
{
input
:
IEditorInput
,
position
:
Position
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[]):
TPromise
<
I
Editor
[]
>
;
replaceEditors
(
editors
:
{
toReplace
:
IEditorInput
,
replaceWith
:
IEditorInput
,
options
?:
IEditorOptions
|
ITextEditorOptions
}[],
position
?:
Position
):
TPromise
<
I
Editor
[]
>
;
closeEditor
(
position
:
Position
,
input
:
IEditorInput
):
TPromise
<
void
>
;
closeEditors
(
position
:
Position
,
filter
?:
{
except
?:
IEditorInput
,
direction
?:
Direction
,
unmodifiedOnly
?:
boolean
}):
TPromise
<
void
>
;
closeAllEditors
(
except
?:
Position
):
TPromise
<
void
>
;
getActiveEditor
():
Base
Editor
;
getActiveEditor
():
I
Editor
;
getVisibleEditors
():
IEditor
[];
getActiveEditorInput
():
IEditorInput
;
}
...
...
@@ -298,8 +297,8 @@ export class WorkbenchEditorService implements IWorkbenchEditorService {
}
export
interface
IEditorOpenHandler
{
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
Base
Editor
>
;
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
position
?:
Position
):
TPromise
<
Base
Editor
>
;
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
sideBySide
?:
boolean
):
TPromise
<
I
Editor
>
;
(
input
:
IEditorInput
,
options
?:
EditorOptions
,
position
?:
Position
):
TPromise
<
I
Editor
>
;
}
export
interface
IEditorCloseHandler
{
...
...
@@ -349,7 +348,7 @@ export class DelegatingWorkbenchEditorService extends WorkbenchEditorService {
return
handleOpen
.
then
(
editor
=>
{
if
(
editor
)
{
return
TPromise
.
as
<
Base
Editor
>
(
editor
);
return
TPromise
.
as
<
I
Editor
>
(
editor
);
}
return
super
.
doOpenEditor
(
input
,
options
,
arg3
);
...
...
src/vs/workbench/services/group/common/groupService.ts
浏览文件 @
f0f2c909
...
...
@@ -7,7 +7,7 @@
import
{
createDecorator
,
ServiceIdentifier
,
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Position
,
IEditorInput
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IEditorStacksModel
,
IEditorGroup
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditorStacksModel
,
IEditorGroup
,
IEditorOpeningEvent
}
from
'
vs/workbench/common/editor
'
;
import
Event
from
'
vs/base/common/event
'
;
export
enum
GroupArrangement
{
...
...
@@ -45,6 +45,11 @@ export interface IEditorGroupService {
*/
onEditorsChanged
:
Event
<
void
>
;
/**
* Emitted when an editor is opening. Allows to prevent/replace the opening via the event method.
*/
onEditorOpening
:
Event
<
IEditorOpeningEvent
>
;
/**
* Emitted when opening an editor fails.
*/
...
...
src/vs/workbench/services/textfile/common/textFileEditorModel.ts
浏览文件 @
f0f2c909
...
...
@@ -765,7 +765,6 @@ export class TextFileEditorModel extends BaseTextEditorModel implements ITextFil
return
this
.
contextService
.
getWorkspace
().
folders
.
some
(
folder
=>
{
return
paths
.
isEqualOrParent
(
this
.
resource
.
fsPath
,
path
.
join
(
folder
.
uri
.
fsPath
,
'
.vscode
'
));
});
}
private
doTouch
():
TPromise
<
void
>
{
...
...
src/vs/workbench/test/workbenchTestServices.ts
浏览文件 @
f0f2c909
...
...
@@ -15,7 +15,7 @@ import URI from 'vs/base/common/uri';
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
StorageService
,
InMemoryLocalStorage
}
from
'
vs/platform/storage/common/storageService
'
;
import
{
IEditorGroup
,
ConfirmResult
}
from
'
vs/workbench/common/editor
'
;
import
{
IEditorGroup
,
ConfirmResult
,
IEditorOpeningEvent
}
from
'
vs/workbench/common/editor
'
;
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
Severity
from
'
vs/base/common/severity
'
;
import
{
IBackupFileService
}
from
'
vs/workbench/services/backup/common/backup
'
;
...
...
@@ -453,6 +453,7 @@ export class TestEditorGroupService implements IEditorGroupService {
private
stacksModel
:
EditorStacksModel
;
private
_onEditorsChanged
:
Emitter
<
void
>
;
private
_onEditorOpening
:
Emitter
<
IEditorOpeningEvent
>
;
private
_onEditorOpenFail
:
Emitter
<
IEditorInput
>
;
private
_onEditorsMoved
:
Emitter
<
void
>
;
private
_onGroupOrientationChanged
:
Emitter
<
void
>
;
...
...
@@ -461,6 +462,7 @@ export class TestEditorGroupService implements IEditorGroupService {
constructor
(
callback
?:
(
method
:
string
)
=>
void
)
{
this
.
_onEditorsMoved
=
new
Emitter
<
void
>
();
this
.
_onEditorsChanged
=
new
Emitter
<
void
>
();
this
.
_onEditorOpening
=
new
Emitter
<
IEditorOpeningEvent
>
();
this
.
_onGroupOrientationChanged
=
new
Emitter
<
void
>
();
this
.
_onEditorOpenFail
=
new
Emitter
<
IEditorInput
>
();
this
.
_onTabOptionsChanged
=
new
Emitter
<
IEditorTabOptions
>
();
...
...
@@ -487,6 +489,10 @@ export class TestEditorGroupService implements IEditorGroupService {
return
this
.
_onEditorsChanged
.
event
;
}
public
get
onEditorOpening
():
Event
<
IEditorOpeningEvent
>
{
return
this
.
_onEditorOpening
.
event
;
}
public
get
onEditorOpenFail
():
Event
<
IEditorInput
>
{
return
this
.
_onEditorOpenFail
.
event
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录