Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
468ea776
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,发现更多精彩内容 >>
提交
468ea776
编写于
9月 19, 2016
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Revert "undo update change for now, #1396"
This reverts commit
83053afc
.
上级
909d4952
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
50 addition
and
39 deletion
+50
-39
src/vs/vscode.d.ts
src/vs/vscode.d.ts
+11
-0
src/vs/workbench/api/node/extHostConfiguration.ts
src/vs/workbench/api/node/extHostConfiguration.ts
+6
-6
src/vs/workbench/test/node/api/extHostConfiguration.test.ts
src/vs/workbench/test/node/api/extHostConfiguration.test.ts
+33
-33
未找到文件。
src/vs/vscode.d.ts
浏览文件 @
468ea776
...
...
@@ -2647,6 +2647,17 @@ declare namespace vscode {
*/
has
(
section
:
string
):
boolean
;
/**
* Update a configuration value. A value can be changed for the current
* [workspace](#workspace.rootPath) only or globally for all instances of the
* editor. The updated configuration values are persisted.
*
* @param section Configuration name, supports _dotted_ names.
* @param value The new value.
* @param global When `true` changes the configuration value for all instances of the editor.
*/
update
(
section
:
string
,
value
:
any
,
global
:
boolean
):
Thenable
<
void
>
;
/**
* Readable dictionary that backs this configuration.
* @readonly
...
...
src/vs/workbench/api/node/extHostConfiguration.ts
浏览文件 @
468ea776
...
...
@@ -9,7 +9,7 @@ import {illegalState} from 'vs/base/common/errors';
import
Event
,
{
Emitter
}
from
'
vs/base/common/event
'
;
import
{
WorkspaceConfiguration
}
from
'
vscode
'
;
import
{
ExtHostConfigurationShape
,
MainThreadConfigurationShape
}
from
'
./extHost.protocol
'
;
//
import {ConfigurationTarget} from 'vs/workbench/services/configuration/common/configurationEditing';
import
{
ConfigurationTarget
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
export
class
ExtHostConfiguration
extends
ExtHostConfigurationShape
{
...
...
@@ -52,11 +52,11 @@ export class ExtHostConfiguration extends ExtHostConfigurationShape {
result
=
defaultValue
;
}
return
result
;
//
},
//
update: (key: string, value: any, global: boolean) => {
//
key = section ? `${section}.${key}` : key;
//
const target = global ? ConfigurationTarget.USER : ConfigurationTarget.WORKSPACE;
//
return this._proxy.$updateConfigurationOption(target, key, value);
},
update
:
(
key
:
string
,
value
:
any
,
global
:
boolean
)
=>
{
key
=
section
?
`
${
section
}
.
${
key
}
`
:
key
;
const
target
=
global
?
ConfigurationTarget
.
USER
:
ConfigurationTarget
.
WORKSPACE
;
return
this
.
_proxy
.
$updateConfigurationOption
(
target
,
key
,
value
);
}
};
...
...
src/vs/workbench/test/node/api/extHostConfiguration.test.ts
浏览文件 @
468ea776
...
...
@@ -9,7 +9,7 @@ import * as assert from 'assert';
import
{
ExtHostConfiguration
}
from
'
vs/workbench/api/node/extHostConfiguration
'
;
import
{
MainThreadConfigurationShape
}
from
'
vs/workbench/api/node/extHost.protocol
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
ConfigurationTarget
/*, ConfigurationEditingErrorCode, IConfigurationEditingError*/
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
import
{
ConfigurationTarget
,
ConfigurationEditingErrorCode
,
IConfigurationEditingError
}
from
'
vs/workbench/services/configuration/common/configurationEditing
'
;
suite
(
'
ExtHostConfiguration
'
,
function
()
{
...
...
@@ -21,49 +21,49 @@ suite('ExtHostConfiguration', function () {
}
};
//
function createExtHostConfiguration(data: any = {}, shape?: MainThreadConfigurationShape) {
//
if (!shape) {
//
shape = new class extends MainThreadConfigurationShape { };
//
}
//
const result = new ExtHostConfiguration(shape);
//
result.$acceptConfigurationChanged(data);
//
return result;
//
}
function
createExtHostConfiguration
(
data
:
any
=
{},
shape
?:
MainThreadConfigurationShape
)
{
if
(
!
shape
)
{
shape
=
new
class
extends
MainThreadConfigurationShape
{
};
}
const
result
=
new
ExtHostConfiguration
(
shape
);
result
.
$acceptConfigurationChanged
(
data
);
return
result
;
}
test
(
'
check illegal state
'
,
function
()
{
assert
.
throws
(()
=>
new
ExtHostConfiguration
(
new
class
extends
MainThreadConfigurationShape
{
}).
getConfiguration
(
'
foo
'
));
});
//
test('udate / section to key', function () {
test
(
'
udate / section to key
'
,
function
()
{
//
const shape = new RecordingShape();
//
const allConfig = createExtHostConfiguration({ foo: { bar: 1, far: 2 } }, shape);
const
shape
=
new
RecordingShape
();
const
allConfig
=
createExtHostConfiguration
({
foo
:
{
bar
:
1
,
far
:
2
}
},
shape
);
//
let config = allConfig.getConfiguration('foo');
//
config.update('bar', 42, true);
let
config
=
allConfig
.
getConfiguration
(
'
foo
'
);
config
.
update
(
'
bar
'
,
42
,
true
);
//
assert.equal(shape.lastArgs[1], 'foo.bar');
//
assert.equal(shape.lastArgs[2], 42);
assert
.
equal
(
shape
.
lastArgs
[
1
],
'
foo.bar
'
);
assert
.
equal
(
shape
.
lastArgs
[
2
],
42
);
//
config = allConfig.getConfiguration('');
//
config.update('bar', 42, true);
//
assert.equal(shape.lastArgs[1], 'bar');
config
=
allConfig
.
getConfiguration
(
''
);
config
.
update
(
'
bar
'
,
42
,
true
);
assert
.
equal
(
shape
.
lastArgs
[
1
],
'
bar
'
);
//
config.update('foo.bar', 42, true);
//
assert.equal(shape.lastArgs[1], 'foo.bar');
//
});
config
.
update
(
'
foo.bar
'
,
42
,
true
);
assert
.
equal
(
shape
.
lastArgs
[
1
],
'
foo.bar
'
);
});
//
test('update / error-state not OK', function () {
test
(
'
update / error-state not OK
'
,
function
()
{
//
const shape = new class extends MainThreadConfigurationShape {
//
$updateConfigurationOption(target: ConfigurationTarget, key: string, value: any): TPromise<any> {
//
return TPromise.wrapError(<IConfigurationEditingError>{ code: ConfigurationEditingErrorCode.ERROR_UNKNOWN_KEY, message: 'Unknown Key' }); // something !== OK
//
}
//
};
const
shape
=
new
class
extends
MainThreadConfigurationShape
{
$updateConfigurationOption
(
target
:
ConfigurationTarget
,
key
:
string
,
value
:
any
):
TPromise
<
any
>
{
return
TPromise
.
wrapError
(
<
IConfigurationEditingError
>
{
code
:
ConfigurationEditingErrorCode
.
ERROR_UNKNOWN_KEY
,
message
:
'
Unknown Key
'
});
// something !== OK
}
};
//
return createExtHostConfiguration({}, shape)
//
.getConfiguration('')
//
.update('', true, false)
//
.then(() => assert.ok(false), err => { /* expecting rejection */});
//
});
return
createExtHostConfiguration
({},
shape
)
.
getConfiguration
(
''
)
.
update
(
''
,
true
,
false
)
.
then
(()
=>
assert
.
ok
(
false
),
err
=>
{
/* expecting rejection */
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录