Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
878a6e0c
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,体验更适合开发者的 AI 搜索 >>
提交
878a6e0c
编写于
9月 10, 2018
作者:
B
Benjamin Pasero
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debt - let extfs.watch() return IDisposable
上级
ec4fb9b9
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
21 addition
and
35 deletion
+21
-35
src/vs/base/node/config.ts
src/vs/base/node/config.ts
+3
-10
src/vs/base/node/extfs.ts
src/vs/base/node/extfs.ts
+7
-3
src/vs/workbench/parts/output/electron-browser/outputServices.ts
...workbench/parts/output/electron-browser/outputServices.ts
+2
-5
src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts
...kbench/parts/snippets/electron-browser/snippetsService.ts
+3
-9
src/vs/workbench/services/files/electron-browser/fileService.ts
.../workbench/services/files/electron-browser/fileService.ts
+6
-8
未找到文件。
src/vs/base/node/config.ts
浏览文件 @
878a6e0c
...
...
@@ -8,7 +8,7 @@
import
*
as
fs
from
'
fs
'
;
import
{
dirname
,
basename
}
from
'
path
'
;
import
*
as
objects
from
'
vs/base/common/objects
'
;
import
{
IDisposable
,
dispose
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IDisposable
,
dispose
}
from
'
vs/base/common/lifecycle
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
*
as
json
from
'
vs/base/common/json
'
;
import
*
as
extfs
from
'
vs/base/node/extfs
'
;
...
...
@@ -152,17 +152,10 @@ export class ConfigWatcher<T> implements IConfigWatcher<T>, IDisposable {
return
;
// avoid watchers that will never get disposed by checking for being disposed
}
const
watcher
=
extfs
.
watch
(
path
,
this
.
disposables
.
push
(
extfs
.
watch
(
path
,
(
type
,
file
)
=>
this
.
onConfigFileChange
(
type
,
file
,
isParentFolder
),
(
error
:
string
)
=>
this
.
options
.
onError
(
error
)
);
if
(
watcher
)
{
this
.
disposables
.
push
(
toDisposable
(()
=>
{
watcher
.
removeAllListeners
();
watcher
.
close
();
}));
}
));
}
private
onConfigFileChange
(
eventType
:
string
,
filename
:
string
,
isParentFolder
:
boolean
):
void
{
...
...
src/vs/base/node/extfs.ts
浏览文件 @
878a6e0c
...
...
@@ -16,6 +16,7 @@ import { TPromise } from 'vs/base/common/winjs.base';
import
{
encode
,
encodeStream
}
from
'
vs/base/node/encoding
'
;
import
*
as
flow
from
'
vs/base/node/flow
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IDisposable
,
toDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
const
loop
=
flow
.
loop
;
...
...
@@ -640,7 +641,7 @@ function normalizePath(path: string): string {
return
strings
.
rtrim
(
paths
.
normalize
(
path
),
paths
.
sep
);
}
export
function
watch
(
path
:
string
,
onChange
:
(
type
:
string
,
path
?:
string
)
=>
void
,
onError
:
(
error
:
string
)
=>
void
):
fs
.
FSWatcher
{
export
function
watch
(
path
:
string
,
onChange
:
(
type
:
string
,
path
?:
string
)
=>
void
,
onError
:
(
error
:
string
)
=>
void
):
IDisposable
{
try
{
const
watcher
=
fs
.
watch
(
path
);
...
...
@@ -660,7 +661,10 @@ export function watch(path: string, onChange: (type: string, path?: string) => v
watcher
.
on
(
'
error
'
,
(
code
:
number
,
signal
:
string
)
=>
onError
(
`Failed to watch
${
path
}
for changes (
${
code
}
,
${
signal
}
)`
));
return
watcher
;
return
toDisposable
(()
=>
{
watcher
.
removeAllListeners
();
watcher
.
close
();
});
}
catch
(
error
)
{
fs
.
exists
(
path
,
exists
=>
{
if
(
exists
)
{
...
...
@@ -669,7 +673,7 @@ export function watch(path: string, onChange: (type: string, path?: string) => v
});
}
return
void
0
;
return
Disposable
.
None
;
}
export
function
sanitizeFilePath
(
candidate
:
string
,
cwd
:
string
):
string
{
...
...
src/vs/workbench/parts/output/electron-browser/outputServices.ts
浏览文件 @
878a6e0c
...
...
@@ -49,7 +49,7 @@ let callbacks: ((eventType: string, fileName: string) => void)[] = [];
function
watchOutputDirectory
(
outputDir
:
string
,
logService
:
ILogService
,
onChange
:
(
eventType
:
string
,
fileName
:
string
)
=>
void
):
IDisposable
{
callbacks
.
push
(
onChange
);
if
(
!
watchingOutputDir
)
{
const
watcher
=
extfs
.
watch
(
outputDir
,
(
eventType
,
fileName
)
=>
{
const
watcher
Disposable
=
extfs
.
watch
(
outputDir
,
(
eventType
,
fileName
)
=>
{
for
(
const
callback
of
callbacks
)
{
callback
(
eventType
,
fileName
);
}
...
...
@@ -59,10 +59,7 @@ function watchOutputDirectory(outputDir: string, logService: ILogService, onChan
watchingOutputDir
=
true
;
return
toDisposable
(()
=>
{
callbacks
=
[];
if
(
watcher
)
{
watcher
.
removeAllListeners
();
watcher
.
close
();
}
watcherDisposable
.
dispose
();
});
}
return
toDisposable
(()
=>
{
});
...
...
src/vs/workbench/parts/snippets/electron-browser/snippetsService.ts
浏览文件 @
878a6e0c
...
...
@@ -7,7 +7,7 @@
import
{
basename
,
extname
,
join
}
from
'
path
'
;
import
{
MarkdownString
}
from
'
vs/base/common/htmlContent
'
;
import
{
IJSONSchema
}
from
'
vs/base/common/jsonSchema
'
;
import
{
dispose
,
IDisposable
,
toDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
dispose
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
values
}
from
'
vs/base/common/map
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
compare
,
endsWith
,
isFalsyOrWhitespace
}
from
'
vs/base/common/strings
'
;
...
...
@@ -234,7 +234,7 @@ class SnippetsService implements ISnippetsService {
}
}).
then
(()
=>
{
// watch
const
watcher
=
watch
(
userSnippetsFolder
,
(
type
,
filename
)
=>
{
this
.
_disposables
.
push
(
watch
(
userSnippetsFolder
,
(
type
,
filename
)
=>
{
if
(
typeof
filename
!==
'
string
'
)
{
return
;
}
...
...
@@ -252,13 +252,7 @@ class SnippetsService implements ISnippetsService {
this
.
_files
.
delete
(
filepath
);
}
});
},
(
error
:
string
)
=>
this
.
_logService
.
error
(
error
));
this
.
_disposables
.
push
(
toDisposable
(()
=>
{
if
(
watcher
)
{
watcher
.
removeAllListeners
();
watcher
.
close
();
}
}));
},
(
error
:
string
)
=>
this
.
_logService
.
error
(
error
)));
}).
then
(
undefined
,
err
=>
{
this
.
_logService
.
error
(
'
Failed to load user snippets
'
,
err
);
...
...
src/vs/workbench/services/files/electron-browser/fileService.ts
浏览文件 @
878a6e0c
...
...
@@ -1003,7 +1003,7 @@ export class FileService extends Disposable implements IFileService {
const
fsPath
=
resource
.
fsPath
;
const
fsName
=
paths
.
basename
(
resource
.
fsPath
);
const
watcher
=
extfs
.
watch
(
fsPath
,
(
eventType
:
string
,
filename
:
string
)
=>
{
const
watcher
Disposable
=
extfs
.
watch
(
fsPath
,
(
eventType
:
string
,
filename
:
string
)
=>
{
const
renamedOrDeleted
=
((
filename
&&
filename
!==
fsName
)
||
eventType
===
'
rename
'
);
// The file was either deleted or renamed. Many tools apply changes to files in an
...
...
@@ -1017,7 +1017,7 @@ export class FileService extends Disposable implements IFileService {
if
(
renamedOrDeleted
)
{
// Very important to dispose the watcher which now points to a stale inode
watcher
.
cl
ose
();
watcher
Disposable
.
disp
ose
();
this
.
activeFileChangesWatchers
.
delete
(
resource
);
// Wait a bit and try to install watcher again, assuming that the file was renamed quickly ("Atomic Save")
...
...
@@ -1048,12 +1048,10 @@ export class FileService extends Disposable implements IFileService {
},
(
error
:
string
)
=>
this
.
handleError
(
error
));
// Remember in map
if
(
watcher
)
{
this
.
activeFileChangesWatchers
.
set
(
resource
,
{
count
:
1
,
unwatch
:
()
=>
watcher
.
close
()
});
}
this
.
activeFileChangesWatchers
.
set
(
resource
,
{
count
:
1
,
unwatch
:
()
=>
watcherDisposable
.
dispose
()
});
}
private
onRawFileChange
(
event
:
IRawFileChange
):
void
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录