Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
6e30aa52
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,发现更多精彩内容 >>
提交
6e30aa52
编写于
11月 19, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - introduce and use in-memory storage for standalone editor
上级
c06861f4
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
73 addition
and
34 deletion
+73
-34
src/vs/editor/contrib/parameterHints/test/parameterHintsModel.test.ts
...r/contrib/parameterHints/test/parameterHintsModel.test.ts
+2
-2
src/vs/editor/contrib/suggest/suggestWidget.ts
src/vs/editor/contrib/suggest/suggestWidget.ts
+2
-21
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
+2
-2
src/vs/editor/standalone/browser/standaloneServices.ts
src/vs/editor/standalone/browser/standaloneServices.ts
+2
-2
src/vs/platform/storage/common/storage.ts
src/vs/platform/storage/common/storage.ts
+65
-7
未找到文件。
src/vs/editor/contrib/parameterHints/test/parameterHintsModel.test.ts
浏览文件 @
6e30aa52
...
...
@@ -14,7 +14,7 @@ import { TextModel } from 'vs/editor/common/model/textModel';
import
*
as
modes
from
'
vs/editor/common/modes
'
;
import
{
createTestCodeEditor
}
from
'
vs/editor/test/browser/testCodeEditor
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IStorageService
,
Null
StorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IStorageService
,
InMemory
StorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
ParameterHintsModel
}
from
'
../parameterHintsWidget
'
;
...
...
@@ -44,7 +44,7 @@ suite('ParameterHintsModel', () => {
model
:
textModel
,
serviceCollection
:
new
ServiceCollection
(
[
ITelemetryService
,
NullTelemetryService
],
[
IStorageService
,
Null
StorageService
]
[
IStorageService
,
InMemory
StorageService
]
)
});
disposables
.
push
(
textModel
);
...
...
src/vs/editor/contrib/suggest/suggestWidget.ts
浏览文件 @
6e30aa52
...
...
@@ -437,9 +437,6 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<IComp
private
detailsFocusBorderColor
:
string
;
private
detailsBorderColor
:
string
;
private
storageServiceAvailable
:
boolean
=
true
;
private
expandSuggestionDocs
:
boolean
=
false
;
private
firstFocusInCurrentList
:
boolean
=
false
;
constructor
(
...
...
@@ -461,14 +458,6 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<IComp
this
.
focusedItem
=
null
;
this
.
storageService
=
storageService
;
// :facepalm: No other smart way to determine if this is monaco or vscode.
// The former doesnt have a storage service
this
.
storageService
.
store
(
'
___suggest___
'
,
true
,
StorageScope
.
GLOBAL
);
if
(
!
this
.
storageService
.
get
(
'
___suggest___
'
,
StorageScope
.
GLOBAL
))
{
this
.
storageServiceAvailable
=
false
;
}
this
.
storageService
.
remove
(
'
___suggest___
'
,
StorageScope
.
GLOBAL
);
this
.
element
=
$
(
'
.editor-widget.suggest-widget
'
);
if
(
!
this
.
editor
.
getConfiguration
().
contribInfo
.
iconsInSuggestions
)
{
addClass
(
this
.
element
,
'
no-icons
'
);
...
...
@@ -1100,19 +1089,11 @@ export class SuggestWidget implements IContentWidget, IListVirtualDelegate<IComp
}
private
expandDocsSettingFromStorage
():
boolean
{
if
(
this
.
storageServiceAvailable
)
{
return
this
.
storageService
.
getBoolean
(
'
expandSuggestionDocs
'
,
StorageScope
.
GLOBAL
,
expandSuggestionDocsByDefault
);
}
else
{
return
this
.
expandSuggestionDocs
;
}
return
this
.
storageService
.
getBoolean
(
'
expandSuggestionDocs
'
,
StorageScope
.
GLOBAL
,
expandSuggestionDocsByDefault
);
}
private
updateExpandDocsSetting
(
value
:
boolean
)
{
if
(
this
.
storageServiceAvailable
)
{
this
.
storageService
.
store
(
'
expandSuggestionDocs
'
,
value
,
StorageScope
.
GLOBAL
);
}
else
{
this
.
expandSuggestionDocs
=
value
;
}
this
.
storageService
.
store
(
'
expandSuggestionDocs
'
,
value
,
StorageScope
.
GLOBAL
);
}
dispose
():
void
{
...
...
src/vs/editor/contrib/suggest/test/suggestModel.test.ts
浏览文件 @
6e30aa52
...
...
@@ -23,7 +23,7 @@ import { ISelectedSuggestion } from 'vs/editor/contrib/suggest/suggestWidget';
import
{
TestCodeEditor
,
createTestCodeEditor
}
from
'
vs/editor/test/browser/testCodeEditor
'
;
import
{
MockMode
}
from
'
vs/editor/test/common/mocks/mockMode
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IStorageService
,
Null
StorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IStorageService
,
InMemory
StorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
NullTelemetryService
}
from
'
vs/platform/telemetry/common/telemetryUtils
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
...
...
@@ -42,7 +42,7 @@ function createMockEditor(model: TextModel): TestCodeEditor {
model
:
model
,
serviceCollection
:
new
ServiceCollection
(
[
ITelemetryService
,
NullTelemetryService
],
[
IStorageService
,
Null
StorageService
]
[
IStorageService
,
InMemory
StorageService
]
),
});
editor
.
registerAndInstantiateContribution
(
SnippetController2
);
...
...
src/vs/editor/standalone/browser/standaloneServices.ts
浏览文件 @
6e30aa52
...
...
@@ -37,7 +37,7 @@ import { MarkerService } from 'vs/platform/markers/common/markerService';
import
{
IMarkerService
}
from
'
vs/platform/markers/common/markers
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
IProgressService
}
from
'
vs/platform/progress/common/progress
'
;
import
{
IStorageService
,
Null
StorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
IStorageService
,
InMemory
StorageService
}
from
'
vs/platform/storage/common/storage
'
;
import
{
ITelemetryService
}
from
'
vs/platform/telemetry/common/telemetry
'
;
import
{
IThemeService
}
from
'
vs/platform/theme/common/themeService
'
;
import
{
IWorkspaceContextService
}
from
'
vs/platform/workspace/common/workspace
'
;
...
...
@@ -143,7 +143,7 @@ export module StaticServices {
export
const
progressService
=
define
(
IProgressService
,
()
=>
new
SimpleProgressService
());
export
const
storageService
=
define
(
IStorageService
,
()
=>
Null
StorageService
);
export
const
storageService
=
define
(
IStorageService
,
()
=>
InMemory
StorageService
);
export
const
logService
=
define
(
ILogService
,
()
=>
new
NullLogService
());
...
...
src/vs/platform/storage/common/storage.ts
浏览文件 @
6e30aa52
...
...
@@ -4,7 +4,9 @@
*--------------------------------------------------------------------------------------------*/
import
{
createDecorator
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
isUndefinedOrNull
}
from
'
vs/base/common/types
'
;
export
const
IStorageService
=
createDecorator
<
IStorageService
>
(
'
storageService
'
);
...
...
@@ -91,32 +93,88 @@ export interface IWorkspaceStorageChangeEvent {
scope
:
StorageScope
;
}
export
const
NullStorageService
:
IStorageService
=
new
class
implements
IStorageService
{
export
const
InMemoryStorageService
:
IStorageService
=
new
class
extends
Disposable
implements
IStorageService
{
_serviceBrand
=
undefined
;
onDidChangeStorage
=
Event
.
None
;
onWillSaveState
=
Event
.
None
;
private
_onDidChangeStorage
:
Emitter
<
IWorkspaceStorageChangeEvent
>
=
this
.
_register
(
new
Emitter
<
IWorkspaceStorageChangeEvent
>
());
get
onDidChangeStorage
():
Event
<
IWorkspaceStorageChangeEvent
>
{
return
this
.
_onDidChangeStorage
.
event
;
}
readonly
onWillSaveState
=
Event
.
None
;
private
globalCache
:
Map
<
string
,
string
>
=
new
Map
<
string
,
string
>
();
private
workspaceCache
:
Map
<
string
,
string
>
=
new
Map
<
string
,
string
>
();
private
getCache
(
scope
:
StorageScope
):
Map
<
string
,
string
>
{
return
scope
===
StorageScope
.
GLOBAL
?
this
.
globalCache
:
this
.
workspaceCache
;
}
get
(
key
:
string
,
scope
:
StorageScope
,
fallbackValue
:
string
):
string
;
get
(
key
:
string
,
scope
:
StorageScope
,
fallbackValue
?:
string
):
string
|
undefined
{
return
fallbackValue
;
const
value
=
this
.
getCache
(
scope
).
get
(
key
);
if
(
isUndefinedOrNull
(
value
))
{
return
fallbackValue
;
}
return
value
;
}
getBoolean
(
key
:
string
,
scope
:
StorageScope
,
fallbackValue
:
boolean
):
boolean
;
getBoolean
(
key
:
string
,
scope
:
StorageScope
,
fallbackValue
?:
boolean
):
boolean
|
undefined
{
return
fallbackValue
;
const
value
=
this
.
getCache
(
scope
).
get
(
key
);
if
(
isUndefinedOrNull
(
value
))
{
return
fallbackValue
;
}
return
value
===
'
true
'
;
}
getInteger
(
key
:
string
,
scope
:
StorageScope
,
fallbackValue
:
number
):
number
;
getInteger
(
key
:
string
,
scope
:
StorageScope
,
fallbackValue
?:
number
):
number
|
undefined
{
return
fallbackValue
;
const
value
=
this
.
getCache
(
scope
).
get
(
key
);
if
(
isUndefinedOrNull
(
value
))
{
return
fallbackValue
;
}
return
parseInt
(
value
,
10
);
}
store
(
key
:
string
,
value
:
any
,
scope
:
StorageScope
):
Promise
<
void
>
{
// We remove the key for undefined/null values
if
(
isUndefinedOrNull
(
value
))
{
return
this
.
remove
(
key
,
scope
);
}
// Otherwise, convert to String and store
const
valueStr
=
String
(
value
);
// Return early if value already set
const
currentValue
=
this
.
getCache
(
scope
).
get
(
key
);
if
(
currentValue
===
valueStr
)
{
return
Promise
.
resolve
();
}
// Update in cache
this
.
getCache
(
scope
).
set
(
key
,
valueStr
);
// Events
this
.
_onDidChangeStorage
.
fire
({
scope
,
key
});
return
Promise
.
resolve
();
}
remove
(
key
:
string
,
scope
:
StorageScope
):
Promise
<
void
>
{
const
wasDeleted
=
this
.
getCache
(
scope
).
delete
(
key
);
if
(
!
wasDeleted
)
{
return
Promise
.
resolve
();
// Return early if value already deleted
}
// Events
this
.
_onDidChangeStorage
.
fire
({
scope
,
key
});
return
Promise
.
resolve
();
}
};
\ No newline at end of file
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录