Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d2ae4d76
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,发现更多精彩内容 >>
提交
d2ae4d76
编写于
3月 02, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix #21706
上级
7bc749b2
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
49 addition
and
28 deletion
+49
-28
src/vs/workbench/common/editor.ts
src/vs/workbench/common/editor.ts
+4
-2
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
.../workbench/parts/preferences/browser/preferencesEditor.ts
+12
-4
src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts
...rkbench/parts/preferences/browser/preferencesRenderers.ts
+4
-0
src/vs/workbench/parts/preferences/browser/preferencesService.ts
...workbench/parts/preferences/browser/preferencesService.ts
+7
-15
src/vs/workbench/parts/preferences/common/preferences.ts
src/vs/workbench/parts/preferences/common/preferences.ts
+2
-2
src/vs/workbench/parts/preferences/common/preferencesContentProvider.ts
...ch/parts/preferences/common/preferencesContentProvider.ts
+4
-2
src/vs/workbench/parts/preferences/common/preferencesModels.ts
...s/workbench/parts/preferences/common/preferencesModels.ts
+16
-3
未找到文件。
src/vs/workbench/common/editor.ts
浏览文件 @
d2ae4d76
...
...
@@ -9,7 +9,7 @@ import Event, { Emitter, once } from 'vs/base/common/event';
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
types
=
require
(
'
vs/base/common/types
'
);
import
URI
from
'
vs/base/common/uri
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IEditor
,
ICommonCodeEditor
,
IEditorViewState
,
IEditorOptions
as
ICodeEditorOptions
,
IModel
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IEditorInput
,
IEditorModel
,
IEditorOptions
,
ITextEditorOptions
,
IBaseResourceInput
,
Position
}
from
'
vs/platform/editor/common/editor
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
...
...
@@ -460,10 +460,11 @@ export interface ITextEditorModel extends IEditorModel {
* connects to the disk to retrieve content and may allow for saving it back or reverting it. Editor models
* are typically cached for some while because they are expensive to construct.
*/
export
class
EditorModel
implements
IEditorModel
{
export
class
EditorModel
extends
Disposable
implements
IEditorModel
{
private
_onDispose
:
Emitter
<
void
>
;
constructor
()
{
super
();
this
.
_onDispose
=
new
Emitter
<
void
>
();
}
...
...
@@ -494,6 +495,7 @@ export class EditorModel implements IEditorModel {
public
dispose
():
void
{
this
.
_onDispose
.
fire
();
this
.
_onDispose
.
dispose
();
super
.
dispose
();
}
}
...
...
src/vs/workbench/parts/preferences/browser/preferencesEditor.ts
浏览文件 @
d2ae4d76
...
...
@@ -465,7 +465,7 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
.
then
(()
=>
this
.
input
.
resolve
()
.
then
(
editorModel
=>
TPromise
.
join
<
any
>
([
editorModel
.
load
(),
this
.
preferencesService
.
resolv
ePreferencesEditorModel
(
editablePreferencesUri
)
this
.
preferencesService
.
creat
ePreferencesEditorModel
(
editablePreferencesUri
)
]))
.
then
(([
editorModel
,
preferencesModel
])
=>
(
<
DefaultPreferencesCodeEditor
>
this
.
getControl
()).
setModels
((
<
ResourceEditorModel
>
editorModel
).
textEditorModel
,
<
SettingsEditorModel
>
preferencesModel
)));
}
...
...
@@ -475,7 +475,7 @@ export class DefaultPreferencesEditor extends BaseTextEditor {
}
public
clearInput
():
void
{
this
.
getControl
().
setModel
(
null
);
(
<
DefaultPreferencesCodeEditor
>
this
.
getControl
()).
clearModels
(
);
super
.
clearInput
();
}
...
...
@@ -504,6 +504,14 @@ class DefaultPreferencesCodeEditor extends CodeEditor {
renderer
.
associatedPreferencesModel
=
this
.
settingsModel
;
}
}
clearModels
():
void
{
if
(
this
.
settingsModel
)
{
this
.
settingsModel
.
dispose
();
this
.
settingsModel
=
null
;
}
super
.
setModel
(
null
);
}
}
export
abstract
class
PreferencesEditorContribution
<
T
>
extends
Disposable
implements
editorCommon
.
IEditorContribution
{
...
...
@@ -557,7 +565,7 @@ export class DefaultSettingsEditorContribution extends PreferencesEditorContribu
static
ID
:
string
=
'
editor.contrib.defaultsettings
'
;
protected
createPreferencesRenderer
():
TPromise
<
IPreferencesRenderer
<
ISetting
>>
{
return
this
.
preferencesService
.
resolv
ePreferencesEditorModel
(
this
.
editor
.
getModel
().
uri
)
return
this
.
preferencesService
.
creat
ePreferencesEditorModel
(
this
.
editor
.
getModel
().
uri
)
.
then
(
editorModel
=>
{
if
(
editorModel
instanceof
DefaultSettingsEditorModel
)
{
return
this
.
instantiationService
.
createInstance
(
DefaultSettingsRenderer
,
this
.
editor
,
editorModel
,
(
<
DefaultPreferencesCodeEditor
>
this
.
editor
).
settingsModel
);
...
...
@@ -581,7 +589,7 @@ export class SettingsEditorContribution extends PreferencesEditorContribution<IS
}
protected
createPreferencesRenderer
():
TPromise
<
IPreferencesRenderer
<
ISetting
>>
{
return
TPromise
.
join
<
any
>
([
this
.
preferencesService
.
create
DefaultPreferencesEditorModel
(
this
.
preferencesService
.
defaultSettingsResource
),
this
.
preferencesService
.
resolv
ePreferencesEditorModel
(
this
.
editor
.
getModel
().
uri
)])
return
TPromise
.
join
<
any
>
([
this
.
preferencesService
.
create
PreferencesEditorModel
(
this
.
preferencesService
.
defaultSettingsResource
),
this
.
preferencesService
.
creat
ePreferencesEditorModel
(
this
.
editor
.
getModel
().
uri
)])
.
then
(([
defaultSettingsModel
,
settingsModel
])
=>
{
if
(
settingsModel
instanceof
SettingsEditorModel
)
{
if
(
ConfigurationTarget
.
USER
===
settingsModel
.
configurationTarget
)
{
...
...
src/vs/workbench/parts/preferences/browser/preferencesRenderers.ts
浏览文件 @
d2ae4d76
...
...
@@ -75,6 +75,8 @@ export class UserSettingsRenderer extends Disposable implements IPreferencesRend
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
)
{
super
();
this
.
_register
(
preferencesModel
);
this
.
_register
(
associatedPreferencesModel
);
this
.
settingHighlighter
=
this
.
_register
(
instantiationService
.
createInstance
(
SettingHighlighter
,
editor
,
this
.
_onFocusPreference
,
this
.
_onClearFocusPreference
));
this
.
highlightPreferencesRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
HighlightPreferencesRenderer
,
editor
));
this
.
editSettingActionRenderer
=
this
.
_register
(
this
.
instantiationService
.
createInstance
(
EditSettingRenderer
,
this
.
editor
,
this
.
preferencesModel
,
this
.
settingHighlighter
));
...
...
@@ -211,6 +213,8 @@ export class DefaultSettingsRenderer extends Disposable implements IPreferencesR
@
IInstantiationService
protected
instantiationService
:
IInstantiationService
)
{
super
();
this
.
_register
(
preferencesModel
);
this
.
_register
(
_associatedPreferencesModel
);
this
.
settingHighlighter
=
this
.
_register
(
instantiationService
.
createInstance
(
SettingHighlighter
,
editor
,
this
.
_onFocusPreference
,
this
.
_onClearFocusPreference
));
this
.
settingsGroupTitleRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
SettingsGroupTitleRenderer
,
editor
));
this
.
filteredMatchesRenderer
=
this
.
_register
(
instantiationService
.
createInstance
(
FilteredMatchesRenderer
,
editor
));
...
...
src/vs/workbench/parts/preferences/browser/preferencesService.ts
浏览文件 @
d2ae4d76
...
...
@@ -88,7 +88,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return
this
.
getEditableSettingsURI
(
ConfigurationTarget
.
WORKSPACE
);
}
create
Default
PreferencesEditorModel
(
uri
:
URI
):
TPromise
<
IPreferencesEditorModel
<
any
>>
{
createPreferencesEditorModel
(
uri
:
URI
):
TPromise
<
IPreferencesEditorModel
<
any
>>
{
let
promise
=
this
.
defaultPreferencesEditorModels
.
get
(
uri
);
if
(
promise
)
{
return
promise
;
...
...
@@ -112,22 +112,13 @@ export class PreferencesService extends Disposable implements IPreferencesServic
return
promise
;
}
return
null
;
}
public
resolvePreferencesEditorModel
(
uri
:
URI
):
TPromise
<
IPreferencesEditorModel
<
any
>>
{
const
promise
=
this
.
defaultPreferencesEditorModels
.
get
(
uri
);
if
(
promise
)
{
return
promise
;
}
if
(
this
.
getEditableSettingsURI
(
ConfigurationTarget
.
USER
).
fsPath
===
uri
.
fsPath
)
{
return
this
.
resolv
eSettingsEditorModel
(
ConfigurationTarget
.
USER
);
return
this
.
createEditabl
eSettingsEditorModel
(
ConfigurationTarget
.
USER
);
}
const
workspaceSettingsUri
=
this
.
getEditableSettingsURI
(
ConfigurationTarget
.
WORKSPACE
);
if
(
workspaceSettingsUri
&&
workspaceSettingsUri
.
fsPath
===
uri
.
fsPath
)
{
return
this
.
resolv
eSettingsEditorModel
(
ConfigurationTarget
.
WORKSPACE
);
return
this
.
createEditabl
eSettingsEditorModel
(
ConfigurationTarget
.
WORKSPACE
);
}
return
TPromise
.
wrap
(
null
);
...
...
@@ -219,11 +210,11 @@ export class PreferencesService extends Disposable implements IPreferencesServic
.
then
(()
=>
this
.
editorService
.
createInput
({
resource
}));
}
private
resolv
eSettingsEditorModel
(
configurationTarget
:
ConfigurationTarget
):
TPromise
<
SettingsEditorModel
>
{
private
createEditabl
eSettingsEditorModel
(
configurationTarget
:
ConfigurationTarget
):
TPromise
<
SettingsEditorModel
>
{
const
settingsUri
=
this
.
getEditableSettingsURI
(
configurationTarget
);
if
(
settingsUri
)
{
return
this
.
textModelResolverService
.
createModelReference
(
settingsUri
)
.
then
(
reference
=>
this
.
instantiationService
.
createInstance
(
SettingsEditorModel
,
reference
.
object
.
textEditorModel
,
configurationTarget
));
.
then
(
reference
=>
this
.
instantiationService
.
createInstance
(
SettingsEditorModel
,
reference
,
configurationTarget
));
}
return
TPromise
.
wrap
(
null
);
}
...
...
@@ -290,7 +281,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
}
private
getPosition
(
language
:
string
,
codeEditor
:
ICommonCodeEditor
):
TPromise
<
IPosition
>
{
return
this
.
resolv
ePreferencesEditorModel
(
this
.
userSettingsResource
)
return
this
.
creat
ePreferencesEditorModel
(
this
.
userSettingsResource
)
.
then
((
settingsModel
:
IPreferencesEditorModel
<
ISetting
>
)
=>
{
const
languageKey
=
`[
${
language
}
]`
;
let
setting
=
settingsModel
.
getPreference
(
languageKey
);
...
...
@@ -319,6 +310,7 @@ export class PreferencesService extends Disposable implements IPreferencesServic
let
editOperation
=
EditOperation
.
insert
(
new
Position
(
setting
.
valueRange
.
endLineNumber
,
setting
.
valueRange
.
endColumn
-
1
),
content
);
model
.
pushEditOperations
([],
[
editOperation
],
()
=>
[]);
let
lineNumber
=
setting
.
valueRange
.
endLineNumber
+
1
;
settingsModel
.
dispose
();
return
{
lineNumber
,
column
:
model
.
getLineMaxColumn
(
lineNumber
)
};
});
});
...
...
src/vs/workbench/parts/preferences/common/preferences.ts
浏览文件 @
d2ae4d76
...
...
@@ -47,6 +47,7 @@ export interface IPreferencesEditorModel<T> {
uri
:
URI
;
content
:
string
;
getPreference
(
key
:
string
):
T
;
dispose
():
void
;
}
export
interface
ISettingsEditorModel
extends
IPreferencesEditorModel
<
ISetting
>
{
...
...
@@ -68,8 +69,7 @@ export interface IPreferencesService {
workspaceSettingsResource
:
URI
;
defaultKeybindingsResource
:
URI
;
createDefaultPreferencesEditorModel
<
T
>
(
uri
:
URI
):
TPromise
<
IPreferencesEditorModel
<
T
>>
;
resolvePreferencesEditorModel
<
T
>
(
uri
:
URI
):
TPromise
<
IPreferencesEditorModel
<
T
>>
;
createPreferencesEditorModel
<
T
>
(
uri
:
URI
):
TPromise
<
IPreferencesEditorModel
<
T
>>
;
openSettings
():
TPromise
<
IEditor
>
;
switchSettings
():
TPromise
<
void
>
;
...
...
src/vs/workbench/parts/preferences/common/preferencesContentProvider.ts
浏览文件 @
d2ae4d76
...
...
@@ -47,11 +47,13 @@ export class PreferencesContentProvider implements IWorkbenchContribution {
return
TPromise
.
as
(
this
.
modelService
.
createModel
(
modelContent
,
mode
,
uri
));
}
}
return
this
.
preferencesService
.
create
Default
PreferencesEditorModel
(
uri
)
return
this
.
preferencesService
.
createPreferencesEditorModel
(
uri
)
.
then
(
preferencesModel
=>
{
if
(
preferencesModel
)
{
let
mode
=
this
.
modeService
.
getOrCreateMode
(
'
json
'
);
return
TPromise
.
as
(
this
.
modelService
.
createModel
(
preferencesModel
.
content
,
mode
,
uri
));
const
model
=
this
.
modelService
.
createModel
(
preferencesModel
.
content
,
mode
,
uri
);
preferencesModel
.
dispose
();
return
TPromise
.
as
(
model
);
}
return
null
;
});
...
...
src/vs/workbench/parts/preferences/common/preferencesModels.ts
浏览文件 @
d2ae4d76
...
...
@@ -8,18 +8,20 @@ import * as strings from 'vs/base/common/strings';
import
{
assign
}
from
'
vs/base/common/objects
'
;
import
{
LinkedMap
as
Map
}
from
'
vs/base/common/map
'
;
import
URI
from
'
vs/base/common/uri
'
;
import
{
Disposabl
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
IReferenc
e
}
from
'
vs/base/common/lifecycle
'
;
import
{
Registry
}
from
'
vs/platform/platform
'
;
import
{
visit
,
JSONVisitor
}
from
'
vs/base/common/json
'
;
import
{
IModel
,
IRange
}
from
'
vs/editor/common/editorCommon
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
EditorModel
}
from
'
vs/workbench/common/editor
'
;
import
{
IConfigurationNode
,
IConfigurationRegistry
,
Extensions
,
OVERRIDE_PROPERTY_PATTERN
}
from
'
vs/platform/configuration/common/configurationRegistry
'
;
import
{
ISettingsEditorModel
,
IKeybindingsEditorModel
,
ISettingsGroup
,
ISetting
,
IFilterResult
,
ISettingsSection
}
from
'
vs/workbench/parts/preferences/common/preferences
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
ConfigurationTarget
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
IMatch
,
or
,
matchesContiguousSubString
,
matchesPrefix
,
matchesCamelCase
,
matchesWords
}
from
'
vs/base/common/filters
'
;
import
{
ITextEditorModel
}
from
'
vs/editor/common/services/resolverService
'
;
export
abstract
class
AbstractSettingsModel
extends
Disposable
{
export
abstract
class
AbstractSettingsModel
extends
EditorModel
{
public
get
groupsTerms
():
string
[]
{
return
this
.
settingsGroups
.
map
(
group
=>
'
@
'
+
group
.
id
);
...
...
@@ -198,9 +200,12 @@ export abstract class AbstractSettingsModel extends Disposable {
export
class
SettingsEditorModel
extends
AbstractSettingsModel
implements
ISettingsEditorModel
{
private
_settingsGroups
:
ISettingsGroup
[];
private
model
:
IModel
;
constructor
(
private
model
:
IModel
,
private
_configurationTarget
:
ConfigurationTarget
)
{
constructor
(
reference
:
IReference
<
ITextEditorModel
>
,
private
_configurationTarget
:
ConfigurationTarget
)
{
super
();
this
.
model
=
reference
.
object
.
textEditorModel
;
this
.
_register
(
this
.
onDispose
(()
=>
reference
.
dispose
()));
this
.
_register
(
this
.
model
.
onDidChangeContent
(()
=>
{
this
.
_settingsGroups
=
null
;
}));
...
...
@@ -625,6 +630,10 @@ export class DefaultSettingsEditorModel extends AbstractSettingsModel implements
result
.
push
(
indent
+
'
//
'
+
line
);
}
}
public
dispose
():
void
{
// Not disposable
}
}
export
class
DefaultKeybindingsEditorModel
implements
IKeybindingsEditorModel
<
any
>
{
...
...
@@ -649,4 +658,8 @@ export class DefaultKeybindingsEditorModel implements IKeybindingsEditorModel<an
public
getPreference
():
any
{
return
null
;
}
public
dispose
():
void
{
// Not disposable
}
}
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录