@@ -14,8 +14,8 @@ import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace
14
14
import { IDisposable , dispose } from 'vs/base/common/lifecycle' ;
15
15
import { memoize } from 'vs/base/common/decorators' ;
16
16
import { Emitter , Event } from 'vs/base/common/event' ;
17
- import { IExplorerService , SortOrder } from 'vs/workbench/contrib/files/common/files' ;
18
17
import { joinPath , isEqualOrParent , basenameOrAuthority } from 'vs/base/common/resources' ;
18
+ import { SortOrder } from 'vs/workbench/contrib/files/common/files' ;
19
19
20
20
export class ExplorerModel implements IDisposable {
21
21
@@ -25,10 +25,10 @@ export class ExplorerModel implements IDisposable {
25
25
26
26
constructor (
27
27
private readonly contextService : IWorkspaceContextService ,
28
- explorerService : IExplorerService
28
+ fileService : IFileService
29
29
) {
30
30
const setRoots = ( ) => this . _roots = this . contextService . getWorkspace ( ) . folders
31
- . map ( folder => new ExplorerItem ( folder . uri , explorerService , undefined , true , false , false , folder . name ) ) ;
31
+ . map ( folder => new ExplorerItem ( folder . uri , fileService , undefined , true , false , folder . name ) ) ;
32
32
setRoots ( ) ;
33
33
34
34
this . _listener = this . contextService . onDidChangeWorkspaceFolders ( ( ) => {
@@ -83,11 +83,10 @@ export class ExplorerItem {
83
83
84
84
constructor (
85
85
public resource : URI ,
86
- private readonly explorerService : IExplorerService ,
86
+ private readonly fileService : IFileService ,
87
87
private _parent : ExplorerItem | undefined ,
88
88
private _isDirectory ?: boolean ,
89
89
private _isSymbolicLink ?: boolean ,
90
- private _isReadonly ?: boolean ,
91
90
private _name : string = basenameOrAuthority ( resource ) ,
92
91
private _mtime ?: number ,
93
92
) {
@@ -112,7 +111,7 @@ export class ExplorerItem {
112
111
}
113
112
114
113
get isReadonly ( ) : boolean {
115
- return ! ! this . _isReadonly ;
114
+ return this . fileService . hasCapability ( this . resource , FileSystemProviderCapabilities . Readonly ) ;
116
115
}
117
116
118
117
get mtime ( ) : number | undefined {
@@ -158,8 +157,8 @@ export class ExplorerItem {
158
157
return this === this . root ;
159
158
}
160
159
161
- static create ( explorerService : IExplorerService , fileService : IFileService , raw : IFileStat , parent : ExplorerItem | undefined , resolveTo ?: readonly URI [ ] ) : ExplorerItem {
162
- const stat = new ExplorerItem ( raw . resource , explorerService , parent , raw . isDirectory , raw . isSymbolicLink , fileService . hasCapability ( raw . resource , FileSystemProviderCapabilities . Readonly ) , raw . name , raw . mtime ) ;
160
+ static create ( fileService : IFileService , raw : IFileStat , parent : ExplorerItem | undefined , resolveTo ?: readonly URI [ ] ) : ExplorerItem {
161
+ const stat = new ExplorerItem ( raw . resource , fileService , parent , raw . isDirectory , raw . isSymbolicLink , raw . name , raw . mtime ) ;
163
162
164
163
// Recursively add children if present
165
164
if ( stat . isDirectory ) {
@@ -174,7 +173,7 @@ export class ExplorerItem {
174
173
// Recurse into children
175
174
if ( raw . children ) {
176
175
for ( let i = 0 , len = raw . children . length ; i < len ; i ++ ) {
177
- const child = ExplorerItem . create ( explorerService , fileService , raw . children [ i ] , stat , resolveTo ) ;
176
+ const child = ExplorerItem . create ( fileService , raw . children [ i ] , stat , resolveTo ) ;
178
177
stat . addChild ( child ) ;
179
178
}
180
179
}
@@ -208,7 +207,6 @@ export class ExplorerItem {
208
207
local . _mtime = disk . mtime ;
209
208
local . _isDirectoryResolved = disk . _isDirectoryResolved ;
210
209
local . _isSymbolicLink = disk . isSymbolicLink ;
211
- local . _isReadonly = disk . isReadonly ;
212
210
local . isError = disk . isError ;
213
211
214
212
// Merge Children if resolved
@@ -259,14 +257,14 @@ export class ExplorerItem {
259
257
return this . children . get ( this . getPlatformAwareName ( name ) ) ;
260
258
}
261
259
262
- async fetchChildren ( fileService : IFileService , explorerService : IExplorerService ) : Promise < ExplorerItem [ ] > {
260
+ async fetchChildren ( sortOrder : SortOrder ) : Promise < ExplorerItem [ ] > {
263
261
if ( ! this . _isDirectoryResolved ) {
264
262
// Resolve metadata only when the mtime is needed since this can be expensive
265
263
// Mtime is only used when the sort order is 'modified'
266
- const resolveMetadata = explorerService . sortOrder === SortOrder . Modified ;
264
+ const resolveMetadata = sortOrder === SortOrder . Modified ;
267
265
try {
268
- const stat = await fileService . resolve ( this . resource , { resolveSingleChildDescendants : true , resolveMetadata } ) ;
269
- const resolved = ExplorerItem . create ( explorerService , fileService , stat , this ) ;
266
+ const stat = await this . fileService . resolve ( this . resource , { resolveSingleChildDescendants : true , resolveMetadata } ) ;
267
+ const resolved = ExplorerItem . create ( this . fileService , stat , this ) ;
270
268
ExplorerItem . mergeLocalWithDisk ( resolved , this ) ;
271
269
} catch ( e ) {
272
270
this . isError = true ;
@@ -306,7 +304,7 @@ export class ExplorerItem {
306
304
}
307
305
308
306
private getPlatformAwareName ( name : string ) : string {
309
- return this . explorerService . shouldIgnoreCase ( this . resource ) ? name . toLowerCase ( ) : name ;
307
+ return this . fileService . hasCapability ( this . resource , FileSystemProviderCapabilities . PathCaseSensitive ) ? name : name . toLowerCase ( ) ;
310
308
}
311
309
312
310
/**
@@ -356,7 +354,7 @@ export class ExplorerItem {
356
354
find ( resource : URI ) : ExplorerItem | null {
357
355
// Return if path found
358
356
// For performance reasons try to do the comparison as fast as possible
359
- const ignoreCase = this . explorerService . shouldIgnoreCase ( resource ) ;
357
+ const ignoreCase = ! this . fileService . hasCapability ( resource , FileSystemProviderCapabilities . PathCaseSensitive ) ;
360
358
if ( resource && this . resource . scheme === resource . scheme && equalsIgnoreCase ( this . resource . authority , resource . authority ) &&
361
359
( ignoreCase ? startsWithIgnoreCase ( resource . path , this . resource . path ) : startsWith ( resource . path , this . resource . path ) ) ) {
362
360
return this . findByPath ( rtrim ( resource . path , posix . sep ) , this . resource . path . length , ignoreCase ) ;
@@ -397,7 +395,7 @@ export class ExplorerItem {
397
395
}
398
396
399
397
export class NewExplorerItem extends ExplorerItem {
400
- constructor ( explorerService : IExplorerService , parent : ExplorerItem , isDirectory : boolean ) {
401
- super ( URI . file ( '' ) , explorerService , parent , isDirectory ) ;
398
+ constructor ( fileService : IFileService , parent : ExplorerItem , isDirectory : boolean ) {
399
+ super ( URI . file ( '' ) , fileService , parent , isDirectory ) ;
402
400
}
403
401
}
0 commit comments