Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c6315a3d
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(gitcode.net)2024年7月9日维护升级公告
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
c6315a3d
编写于
3月 05, 2019
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - more services cleanup
上级
f0983abe
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
134 addition
and
46 deletion
+134
-46
src/vs/platform/lifecycle/common/lifecycle.ts
src/vs/platform/lifecycle/common/lifecycle.ts
+1
-1
src/vs/workbench/electron-browser/workbench.ts
src/vs/workbench/electron-browser/workbench.ts
+48
-40
src/vs/workbench/services/backup/node/backupFileService.ts
src/vs/workbench/services/backup/node/backupFileService.ts
+64
-3
src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts
...es/backup/test/electron-browser/backupFileService.test.ts
+20
-2
src/vs/workbench/workbench.main.ts
src/vs/workbench/workbench.main.ts
+1
-0
未找到文件。
src/vs/platform/lifecycle/common/lifecycle.ts
浏览文件 @
c6315a3d
...
...
@@ -133,7 +133,7 @@ export interface ILifecycleService {
/**
* A flag indicating in what phase of the lifecycle we currently are.
*/
readonly
phase
:
LifecyclePhase
;
phase
:
LifecyclePhase
;
/**
* Fired before shutdown happens. Allows listeners to veto against the
...
...
src/vs/workbench/electron-browser/workbench.ts
浏览文件 @
c6315a3d
...
...
@@ -105,8 +105,6 @@ import { WorkbenchContextKeysHandler } from 'vs/workbench/browser/contextkeys';
import
{
ServicesAccessor
}
from
'
vs/editor/browser/editorExtensions
'
;
// import@node
import
{
BackupFileService
,
InMemoryBackupFileService
}
from
'
vs/workbench/services/backup/node/backupFileService
'
;
import
{
WorkspaceService
}
from
'
vs/workbench/services/configuration/node/configurationService
'
;
import
{
getDelayedChannel
}
from
'
vs/base/parts/ipc/node/ipc
'
;
import
{
connect
as
connectNet
}
from
'
vs/base/parts/ipc/node/ipc.net
'
;
import
{
DialogChannel
}
from
'
vs/platform/dialogs/node/dialogIpc
'
;
...
...
@@ -190,13 +188,13 @@ export class Workbench extends Disposable implements IPartService {
private
editorService
:
EditorService
;
private
editorGroupService
:
IEditorGroupsService
;
private
contextViewService
:
ContextViewService
;
private
backupFileService
:
IBackupFileService
;
private
windowService
:
IWindowService
;
private
lifecycleService
:
LifecycleService
;
private
lifecycleService
:
ILifecycleService
;
private
instantiationService
:
IInstantiationService
;
private
contextService
:
IWorkspaceContextService
;
private
storageService
:
IStorageService
;
private
configurationService
:
Workspace
Service
;
private
configurationService
:
IConfiguration
Service
;
private
environmentService
:
IEnvironmentService
;
private
logService
:
ILogService
;
private
windowsService
:
IWindowsService
;
...
...
@@ -221,7 +219,7 @@ export class Workbench extends Disposable implements IPartService {
@
IInstantiationService
instantiationService
:
IInstantiationService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IStorageService
storageService
:
IStorageService
,
@
IConfigurationService
configurationService
:
Workspace
Service
,
@
IConfigurationService
configurationService
:
IConfiguration
Service
,
@
IEnvironmentService
environmentService
:
IEnvironmentService
,
@
ILogService
logService
:
ILogService
,
@
IWindowsService
windowsService
:
IWindowsService
...
...
@@ -333,7 +331,7 @@ export class Workbench extends Disposable implements IPartService {
this
.
registerLayoutListeners
();
// Layout State
this
.
in
itLayoutState
(
);
this
.
in
stantiationService
.
invokeFunction
(
accessor
=>
this
.
initLayoutState
(
accessor
)
);
// Render Workbench
this
.
renderWorkbench
();
...
...
@@ -525,14 +523,6 @@ export class Workbench extends Disposable implements IPartService {
// History
serviceCollection
.
set
(
IHistoryService
,
new
SyncDescriptor
(
HistoryService
));
// Backup File Service
if
(
this
.
configuration
.
backupPath
)
{
this
.
backupFileService
=
this
.
instantiationService
.
createInstance
(
BackupFileService
,
this
.
configuration
.
backupPath
);
}
else
{
this
.
backupFileService
=
new
InMemoryBackupFileService
();
}
serviceCollection
.
set
(
IBackupFileService
,
this
.
backupFileService
);
// Quick open service (quick open controller)
this
.
quickOpen
=
this
.
instantiationService
.
createInstance
(
QuickOpenController
);
serviceCollection
.
set
(
IQuickOpenService
,
this
.
quickOpen
);
...
...
@@ -561,12 +551,20 @@ export class Workbench extends Disposable implements IPartService {
this
.
instantiationService
.
invokeFunction
(
accessor
=>
{
const
fileService
=
accessor
.
get
(
IFileService
);
const
instantiationService
=
accessor
.
get
(
IInstantiationService
);
const
themeService
=
accessor
.
get
(
IWorkbenchThemeService
)
as
WorkbenchThemeService
;
const
configurationService
=
accessor
.
get
(
IConfigurationService
)
as
any
;
const
themeService
=
accessor
.
get
(
IWorkbenchThemeService
)
as
any
;
this
.
configurationService
.
acquireFileService
(
fileService
);
this
.
configurationService
.
acquireInstantiationService
(
instantiationService
);
if
(
typeof
configurationService
.
acquireFileService
===
'
function
'
)
{
configurationService
.
acquireFileService
(
fileService
);
}
if
(
typeof
configurationService
.
acquireInstantiationService
===
'
function
'
)
{
configurationService
.
acquireInstantiationService
(
instantiationService
);
}
themeService
.
acquireFileService
(
fileService
);
if
(
typeof
themeService
.
acquireFileService
===
'
function
'
)
{
themeService
.
acquireFileService
(
fileService
);
}
});
}
...
...
@@ -785,7 +783,7 @@ export class Workbench extends Disposable implements IPartService {
}
private
whenStarted
(
accessor
:
ServicesAccessor
,
error
?:
Error
):
void
{
const
lifecycleService
=
accessor
.
get
(
ILifecycleService
)
as
LifecycleService
;
const
lifecycleService
=
accessor
.
get
(
ILifecycleService
);
this
.
restored
=
true
;
...
...
@@ -1020,22 +1018,27 @@ export class Workbench extends Disposable implements IPartService {
}
}
private
initLayoutState
():
void
{
private
initLayoutState
(
accessor
:
ServicesAccessor
):
void
{
const
configurationService
=
accessor
.
get
(
IConfigurationService
);
const
storageService
=
accessor
.
get
(
IStorageService
);
const
lifecycleService
=
accessor
.
get
(
ILifecycleService
);
const
contextService
=
accessor
.
get
(
IWorkspaceContextService
);
const
environmentService
=
accessor
.
get
(
IEnvironmentService
);
// Fullscreen
this
.
state
.
fullscreen
=
isFullscreen
();
// Menubar visibility
this
.
state
.
menuBar
.
visibility
=
this
.
configurationService
.
getValue
<
MenuBarVisibility
>
(
Settings
.
MENUBAR_VISIBLE
);
this
.
state
.
menuBar
.
visibility
=
configurationService
.
getValue
<
MenuBarVisibility
>
(
Settings
.
MENUBAR_VISIBLE
);
// Activity bar visibility
this
.
state
.
activityBar
.
hidden
=
!
this
.
configurationService
.
getValue
<
string
>
(
Settings
.
ACTIVITYBAR_VISIBLE
);
this
.
state
.
activityBar
.
hidden
=
!
configurationService
.
getValue
<
string
>
(
Settings
.
ACTIVITYBAR_VISIBLE
);
// Sidebar visibility
this
.
state
.
sideBar
.
hidden
=
this
.
storageService
.
getBoolean
(
Storage
.
SIDEBAR_HIDDEN
,
StorageScope
.
WORKSPACE
,
this
.
contextService
.
getWorkbenchState
()
===
WorkbenchState
.
EMPTY
);
this
.
state
.
sideBar
.
hidden
=
storageService
.
getBoolean
(
Storage
.
SIDEBAR_HIDDEN
,
StorageScope
.
WORKSPACE
,
contextService
.
getWorkbenchState
()
===
WorkbenchState
.
EMPTY
);
// Sidebar position
this
.
state
.
sideBar
.
position
=
(
this
.
configurationService
.
getValue
<
string
>
(
Settings
.
SIDEBAR_POSITION
)
===
'
right
'
)
?
Position
.
RIGHT
:
Position
.
LEFT
;
this
.
state
.
sideBar
.
position
=
(
configurationService
.
getValue
<
string
>
(
Settings
.
SIDEBAR_POSITION
)
===
'
right
'
)
?
Position
.
RIGHT
:
Position
.
LEFT
;
// Sidebar viewlet
if
(
!
this
.
state
.
sideBar
.
hidden
)
{
...
...
@@ -1043,8 +1046,8 @@ export class Workbench extends Disposable implements IPartService {
// Only restore last viewlet if window was reloaded or we are in development mode
let
viewletToRestore
:
string
;
if
(
!
this
.
environmentService
.
isBuilt
||
this
.
lifecycleService
.
startupKind
===
StartupKind
.
ReloadedWindow
)
{
viewletToRestore
=
this
.
storageService
.
get
(
SidebarPart
.
activeViewletSettingsKey
,
StorageScope
.
WORKSPACE
,
viewletRegistry
.
getDefaultViewletId
());
if
(
!
environmentService
.
isBuilt
||
lifecycleService
.
startupKind
===
StartupKind
.
ReloadedWindow
)
{
viewletToRestore
=
storageService
.
get
(
SidebarPart
.
activeViewletSettingsKey
,
StorageScope
.
WORKSPACE
,
viewletRegistry
.
getDefaultViewletId
());
}
else
{
viewletToRestore
=
viewletRegistry
.
getDefaultViewletId
();
}
...
...
@@ -1057,13 +1060,13 @@ export class Workbench extends Disposable implements IPartService {
}
// Editor centered layout
this
.
state
.
editor
.
restoreCentered
=
this
.
storageService
.
getBoolean
(
Storage
.
CENTERED_LAYOUT_ENABLED
,
StorageScope
.
WORKSPACE
,
false
);
this
.
state
.
editor
.
restoreCentered
=
storageService
.
getBoolean
(
Storage
.
CENTERED_LAYOUT_ENABLED
,
StorageScope
.
WORKSPACE
,
false
);
// Editors to open
this
.
state
.
editor
.
editorsToOpen
=
this
.
resolveEditorsToOpen
();
this
.
state
.
editor
.
editorsToOpen
=
this
.
resolveEditorsToOpen
(
accessor
);
// Panel visibility
this
.
state
.
panel
.
hidden
=
this
.
storageService
.
getBoolean
(
Storage
.
PANEL_HIDDEN
,
StorageScope
.
WORKSPACE
,
true
);
this
.
state
.
panel
.
hidden
=
storageService
.
getBoolean
(
Storage
.
PANEL_HIDDEN
,
StorageScope
.
WORKSPACE
,
true
);
// Panel position
this
.
updatePanelPosition
();
...
...
@@ -1072,7 +1075,7 @@ export class Workbench extends Disposable implements IPartService {
if
(
!
this
.
state
.
panel
.
hidden
)
{
const
panelRegistry
=
Registry
.
as
<
PanelRegistry
>
(
PanelExtensions
.
Panels
);
let
panelToRestore
=
this
.
storageService
.
get
(
PanelPart
.
activePanelSettingsKey
,
StorageScope
.
WORKSPACE
,
panelRegistry
.
getDefaultPanelId
());
let
panelToRestore
=
storageService
.
get
(
PanelPart
.
activePanelSettingsKey
,
StorageScope
.
WORKSPACE
,
panelRegistry
.
getDefaultPanelId
());
if
(
!
panelRegistry
.
hasPanel
(
panelToRestore
))
{
panelToRestore
=
panelRegistry
.
getDefaultPanelId
();
// fallback to default if panel is unknown
}
...
...
@@ -1085,19 +1088,24 @@ export class Workbench extends Disposable implements IPartService {
}
// Statusbar visibility
this
.
state
.
statusBar
.
hidden
=
!
this
.
configurationService
.
getValue
<
string
>
(
Settings
.
STATUSBAR_VISIBLE
);
this
.
state
.
statusBar
.
hidden
=
!
configurationService
.
getValue
<
string
>
(
Settings
.
STATUSBAR_VISIBLE
);
// Zen mode enablement
this
.
state
.
zenMode
.
restore
=
this
.
storageService
.
getBoolean
(
Storage
.
ZEN_MODE_ENABLED
,
StorageScope
.
WORKSPACE
,
false
)
&&
this
.
configurationService
.
getValue
(
Settings
.
ZEN_MODE_RESTORE
);
this
.
state
.
zenMode
.
restore
=
storageService
.
getBoolean
(
Storage
.
ZEN_MODE_ENABLED
,
StorageScope
.
WORKSPACE
,
false
)
&&
configurationService
.
getValue
(
Settings
.
ZEN_MODE_RESTORE
);
}
private
resolveEditorsToOpen
():
Promise
<
IResourceEditor
[]
>
|
IResourceEditor
[]
{
private
resolveEditorsToOpen
(
accessor
:
ServicesAccessor
):
Promise
<
IResourceEditor
[]
>
|
IResourceEditor
[]
{
const
configuration
=
accessor
.
get
(
IWindowService
).
getConfiguration
();
const
configurationService
=
accessor
.
get
(
IConfigurationService
);
const
contextService
=
accessor
.
get
(
IWorkspaceContextService
);
const
editorGroupService
=
accessor
.
get
(
IEditorGroupsService
);
const
backupFileService
=
accessor
.
get
(
IBackupFileService
);
// Files to open, diff or create
if
(
this
.
hasInitialFilesToOpen
())
{
// Files to diff is exclusive
const
filesToDiff
=
this
.
toInputs
(
this
.
configuration
.
filesToDiff
,
false
);
const
filesToDiff
=
this
.
toInputs
(
configuration
.
filesToDiff
,
false
);
if
(
filesToDiff
&&
filesToDiff
.
length
===
2
)
{
return
[
<
IResourceDiffInput
>
{
leftResource
:
filesToDiff
[
0
].
resource
,
...
...
@@ -1107,21 +1115,21 @@ export class Workbench extends Disposable implements IPartService {
}];
}
const
filesToCreate
=
this
.
toInputs
(
this
.
configuration
.
filesToCreate
,
true
);
const
filesToOpen
=
this
.
toInputs
(
this
.
configuration
.
filesToOpen
,
false
);
const
filesToCreate
=
this
.
toInputs
(
configuration
.
filesToCreate
,
true
);
const
filesToOpen
=
this
.
toInputs
(
configuration
.
filesToOpen
,
false
);
// Otherwise: Open/Create files
return
[...
filesToOpen
,
...
filesToCreate
];
}
// Empty workbench
else
if
(
this
.
contextService
.
getWorkbenchState
()
===
WorkbenchState
.
EMPTY
&&
this
.
configurationService
.
inspect
(
'
workbench.startupEditor
'
).
value
===
'
newUntitledFile
'
)
{
const
isEmpty
=
this
.
editorGroupService
.
count
===
1
&&
this
.
editorGroupService
.
activeGroup
.
count
===
0
;
else
if
(
contextService
.
getWorkbenchState
()
===
WorkbenchState
.
EMPTY
&&
configurationService
.
inspect
(
'
workbench.startupEditor
'
).
value
===
'
newUntitledFile
'
)
{
const
isEmpty
=
editorGroupService
.
count
===
1
&&
editorGroupService
.
activeGroup
.
count
===
0
;
if
(
!
isEmpty
)
{
return
[];
// do not open any empty untitled file if we restored editors from previous session
}
return
this
.
backupFileService
.
hasBackups
().
then
(
hasBackups
=>
{
return
backupFileService
.
hasBackups
().
then
(
hasBackups
=>
{
if
(
hasBackups
)
{
return
[];
// do not open any empty untitled file if we have backups to restore
}
...
...
src/vs/workbench/services/backup/node/backupFileService.ts
浏览文件 @
c6315a3d
...
...
@@ -15,6 +15,8 @@ import { ITextBufferFactory } from 'vs/editor/common/model';
import
{
createTextBufferFactoryFromStream
,
createTextBufferFactoryFromSnapshot
}
from
'
vs/editor/common/model/textModel
'
;
import
{
keys
}
from
'
vs/base/common/map
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IWindowService
}
from
'
vs/platform/windows/common/windows
'
;
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
export
interface
IBackupFilesModel
{
resolve
(
backupRoot
:
string
):
Promise
<
IBackupFilesModel
>
;
...
...
@@ -107,6 +109,63 @@ export class BackupFilesModel implements IBackupFilesModel {
export
class
BackupFileService
implements
IBackupFileService
{
_serviceBrand
:
any
;
private
impl
:
IBackupFileService
;
constructor
(
@
IWindowService
windowService
:
IWindowService
,
@
IFileService
fileService
:
IFileService
)
{
const
backupWorkspacePath
=
windowService
.
getConfiguration
().
backupPath
;
if
(
backupWorkspacePath
)
{
this
.
impl
=
new
BackupFileServiceImpl
(
backupWorkspacePath
,
fileService
);
}
else
{
this
.
impl
=
new
InMemoryBackupFileService
();
}
}
initialize
(
backupWorkspacePath
:
string
):
void
{
if
(
this
.
impl
instanceof
BackupFileServiceImpl
)
{
this
.
impl
.
initialize
(
backupWorkspacePath
);
}
}
hasBackups
():
Promise
<
boolean
>
{
return
this
.
impl
.
hasBackups
();
}
loadBackupResource
(
resource
:
Uri
):
Promise
<
Uri
|
undefined
>
{
return
this
.
impl
.
loadBackupResource
(
resource
);
}
backupResource
(
resource
:
Uri
,
content
:
ITextSnapshot
,
versionId
?:
number
):
Promise
<
void
>
{
return
this
.
impl
.
backupResource
(
resource
,
content
,
versionId
);
}
discardResourceBackup
(
resource
:
Uri
):
Promise
<
void
>
{
return
this
.
impl
.
discardResourceBackup
(
resource
);
}
discardAllWorkspaceBackups
():
Promise
<
void
>
{
return
this
.
impl
.
discardAllWorkspaceBackups
();
}
getWorkspaceFileBackups
():
Promise
<
Uri
[]
>
{
return
this
.
impl
.
getWorkspaceFileBackups
();
}
resolveBackupContent
(
backup
:
Uri
):
Promise
<
ITextBufferFactory
>
{
return
this
.
impl
.
resolveBackupContent
(
backup
);
}
toBackupResource
(
resource
:
Uri
):
Uri
{
return
this
.
impl
.
toBackupResource
(
resource
);
}
}
class
BackupFileServiceImpl
implements
IBackupFileService
{
private
static
readonly
META_MARKER
=
'
\n
'
;
_serviceBrand
:
any
;
...
...
@@ -170,7 +229,7 @@ export class BackupFileService implements IBackupFileService {
}
return
this
.
ioOperationQueues
.
queueFor
(
backupResource
).
queue
(()
=>
{
const
preamble
=
`
${
resource
.
toString
()}${
BackupFileService
.
META_MARKER
}
`
;
const
preamble
=
`
${
resource
.
toString
()}${
BackupFileService
Impl
.
META_MARKER
}
`
;
// Update content with value
return
this
.
fileService
.
updateContent
(
backupResource
,
new
BackupSnapshot
(
content
,
preamble
),
BACKUP_FILE_UPDATE_OPTIONS
).
then
(()
=>
model
.
add
(
backupResource
,
versionId
));
...
...
@@ -202,7 +261,7 @@ export class BackupFileService implements IBackupFileService {
model
.
get
().
forEach
(
fileBackup
=>
{
readPromises
.
push
(
readToMatchingString
(
fileBackup
.
fsPath
,
BackupFileService
.
META_MARKER
,
2000
,
10000
).
then
(
Uri
.
parse
)
readToMatchingString
(
fileBackup
.
fsPath
,
BackupFileService
Impl
.
META_MARKER
,
2000
,
10000
).
then
(
Uri
.
parse
)
);
});
...
...
@@ -217,7 +276,7 @@ export class BackupFileService implements IBackupFileService {
let
metaFound
=
false
;
const
metaPreambleFilter
=
(
chunk
:
string
)
=>
{
if
(
!
metaFound
&&
chunk
)
{
const
metaIndex
=
chunk
.
indexOf
(
BackupFileService
.
META_MARKER
);
const
metaIndex
=
chunk
.
indexOf
(
BackupFileService
Impl
.
META_MARKER
);
if
(
metaIndex
===
-
1
)
{
return
''
;
// meta not yet found, return empty string
}
...
...
@@ -302,3 +361,5 @@ export function hashPath(resource: Uri): string {
const
str
=
resource
.
scheme
===
Schemas
.
file
?
resource
.
fsPath
:
resource
.
toString
();
return
crypto
.
createHash
(
'
md5
'
).
update
(
str
).
digest
(
'
hex
'
);
}
registerSingleton
(
IBackupFileService
,
BackupFileService
);
\ No newline at end of file
src/vs/workbench/services/backup/test/electron-browser/backupFileService.test.ts
浏览文件 @
c6315a3d
...
...
@@ -13,7 +13,7 @@ import { URI as Uri } from 'vs/base/common/uri';
import
{
BackupFileService
,
BackupFilesModel
,
hashPath
}
from
'
vs/workbench/services/backup/node/backupFileService
'
;
import
{
FileService
}
from
'
vs/workbench/services/files/node/fileService
'
;
import
{
TextModel
,
createTextBufferFactory
}
from
'
vs/editor/common/model/textModel
'
;
import
{
TestContextService
,
TestTextResourceConfigurationService
,
TestLifecycleService
,
TestEnvironmentService
,
TestStorageService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
TestContextService
,
TestTextResourceConfigurationService
,
TestLifecycleService
,
TestEnvironmentService
,
TestStorageService
,
TestWindowService
}
from
'
vs/workbench/test/workbenchTestServices
'
;
import
{
getRandomTestPath
}
from
'
vs/base/test/node/testUtils
'
;
import
{
TestNotificationService
}
from
'
vs/platform/notification/test/common/testNotificationService
'
;
import
{
Workspace
,
toWorkspaceFolders
}
from
'
vs/platform/workspace/common/workspace
'
;
...
...
@@ -21,6 +21,7 @@ import { TestConfigurationService } from 'vs/platform/configuration/test/common/
import
{
DefaultEndOfLine
}
from
'
vs/editor/common/model
'
;
import
{
snapshotToString
}
from
'
vs/platform/files/common/files
'
;
import
{
Schemas
}
from
'
vs/base/common/network
'
;
import
{
IWindowConfiguration
}
from
'
vs/platform/windows/common/windows
'
;
const
parentDir
=
getRandomTestPath
(
os
.
tmpdir
(),
'
vsctests
'
,
'
backupfileservice
'
);
const
backupHome
=
path
.
join
(
parentDir
,
'
Backups
'
);
...
...
@@ -35,11 +36,28 @@ const fooBackupPath = path.join(workspaceBackupPath, 'file', hashPath(fooFile));
const
barBackupPath
=
path
.
join
(
workspaceBackupPath
,
'
file
'
,
hashPath
(
barFile
));
const
untitledBackupPath
=
path
.
join
(
workspaceBackupPath
,
'
untitled
'
,
hashPath
(
untitledFile
));
class
TestBackupWindowService
extends
TestWindowService
{
private
config
:
IWindowConfiguration
;
constructor
(
workspaceBackupPath
:
string
)
{
super
();
this
.
config
=
Object
.
create
(
null
);
this
.
config
.
backupPath
=
workspaceBackupPath
;
}
getConfiguration
():
IWindowConfiguration
{
return
this
.
config
;
}
}
class
TestBackupFileService
extends
BackupFileService
{
constructor
(
workspace
:
Uri
,
backupHome
:
string
,
workspacesJsonPath
:
string
)
{
const
fileService
=
new
FileService
(
new
TestContextService
(
new
Workspace
(
workspace
.
fsPath
,
toWorkspaceFolders
([{
path
:
workspace
.
fsPath
}]))),
TestEnvironmentService
,
new
TestTextResourceConfigurationService
(),
new
TestConfigurationService
(),
new
TestLifecycleService
(),
new
TestStorageService
(),
new
TestNotificationService
(),
{
disableWatcher
:
true
});
const
windowService
=
new
TestBackupWindowService
(
workspaceBackupPath
);
super
(
w
orkspaceBackupPath
,
fileService
);
super
(
w
indowService
,
fileService
);
}
public
toBackupResource
(
resource
:
Uri
):
Uri
{
...
...
src/vs/workbench/workbench.main.ts
浏览文件 @
c6315a3d
...
...
@@ -73,6 +73,7 @@ import 'vs/workbench/services/configuration/node/jsonEditingService';
import
'
vs/workbench/services/textmodelResolver/common/textModelResolverService
'
;
import
'
vs/workbench/services/textfile/common/textFileService
'
;
import
'
vs/workbench/services/dialogs/electron-browser/dialogService
'
;
import
'
vs/workbench/services/backup/node/backupFileService
'
;
registerSingleton
(
IMenuService
,
MenuService
,
true
);
registerSingleton
(
IListService
,
ListService
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录