Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ce4d70b4
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,发现更多精彩内容 >>
未验证
提交
ce4d70b4
编写于
9月 03, 2018
作者:
S
Sandeep Somavarapu
提交者:
GitHub
9月 03, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #57809 from Microsoft/sandy081/40533
Use file service to listen to changes
上级
6e91e580
eb0f00a4
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
15 addition
and
49 deletion
+15
-49
src/vs/platform/files/common/files.ts
src/vs/platform/files/common/files.ts
+6
-4
src/vs/workbench/parts/output/electron-browser/outputServices.ts
...workbench/parts/output/electron-browser/outputServices.ts
+9
-45
未找到文件。
src/vs/platform/files/common/files.ts
浏览文件 @
ce4d70b4
...
...
@@ -284,22 +284,24 @@ export class FileChangesEvent {
}
/**
* Returns true if this change event contains the provided file with the given change type. In case of
* Returns true if this change event contains the provided file with the given change type
(if provided)
. In case of
* type DELETED, this method will also return true if a folder got deleted that is the parent of the
* provided file path.
*/
contains
(
resource
:
URI
,
type
:
FileChangeType
):
boolean
{
contains
(
resource
:
URI
,
type
?
:
FileChangeType
):
boolean
{
if
(
!
resource
)
{
return
false
;
}
const
checkForChangeType
=
!
isUndefinedOrNull
(
type
);
return
this
.
_changes
.
some
(
change
=>
{
if
(
change
.
type
!==
type
)
{
if
(
ch
eckForChangeType
&&
ch
ange
.
type
!==
type
)
{
return
false
;
}
// For deleted also return true when deleted folder is parent of target path
if
(
type
===
FileChangeType
.
DELETED
)
{
if
(
change
.
type
===
FileChangeType
.
DELETED
)
{
return
isEqualOrParent
(
resource
,
change
.
resource
,
!
isLinux
/* ignorecase */
);
}
...
...
src/vs/workbench/parts/output/electron-browser/outputServices.ts
浏览文件 @
ce4d70b4
...
...
@@ -6,7 +6,6 @@
import
*
as
nls
from
'
vs/nls
'
;
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
extfs
from
'
vs/base/node/extfs
'
;
import
*
as
fs
from
'
fs
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
Event
,
Emitter
}
from
'
vs/base/common/event
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
...
...
@@ -67,46 +66,6 @@ function watchOutputDirectory(outputDir: string, logService: ILogService, onChan
return
toDisposable
(()
=>
{
});
}
const
fileWatchers
:
Map
<
string
,
any
[]
>
=
new
Map
<
string
,
any
[]
>
();
function
watchFile
(
file
:
string
,
callback
:
()
=>
void
):
IDisposable
{
const
onFileChange
=
(
file
:
string
)
=>
{
for
(
const
callback
of
fileWatchers
.
get
(
file
))
{
callback
();
}
};
let
callbacks
=
fileWatchers
.
get
(
file
);
if
(
!
callbacks
)
{
callbacks
=
[];
fileWatchers
.
set
(
file
,
callbacks
);
fs
.
watchFile
(
file
,
{
interval
:
1000
},
(
current
,
previous
)
=>
{
if
((
previous
&&
!
current
)
||
(
!
previous
&&
!
current
))
{
onFileChange
(
file
);
return
;
}
if
(
previous
&&
current
&&
previous
.
mtime
!==
current
.
mtime
)
{
onFileChange
(
file
);
return
;
}
});
}
callbacks
.
push
(
callback
);
return
toDisposable
(()
=>
{
let
allCallbacks
=
fileWatchers
.
get
(
file
);
allCallbacks
.
splice
(
allCallbacks
.
indexOf
(
callback
),
1
);
if
(
!
allCallbacks
.
length
)
{
fs
.
unwatchFile
(
file
);
fileWatchers
.
delete
(
file
);
}
});
}
function
unWatchAllFiles
():
void
{
fileWatchers
.
forEach
((
value
,
file
)
=>
fs
.
unwatchFile
(
file
));
fileWatchers
.
clear
();
}
interface
OutputChannel
extends
IOutputChannel
{
readonly
file
:
URI
;
readonly
onDidAppendedContent
:
Event
<
void
>
;
...
...
@@ -323,19 +282,26 @@ class OutputFileListener extends Disposable {
constructor
(
private
readonly
file
:
URI
,
private
readonly
fileService
:
IFileService
)
{
super
();
}
watch
():
void
{
if
(
!
this
.
watching
)
{
this
.
disposables
.
push
(
watchFile
(
this
.
file
.
fsPath
,
()
=>
this
.
_onDidChange
.
fire
()));
this
.
fileService
.
watchFileChanges
(
this
.
file
);
this
.
disposables
.
push
(
this
.
fileService
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
this
.
file
))
{
this
.
_onDidChange
.
fire
();
}
}));
this
.
watching
=
true
;
}
}
unwatch
():
void
{
if
(
this
.
watching
)
{
this
.
fileService
.
unwatchFileChanges
(
this
.
file
);
this
.
disposables
=
dispose
(
this
.
disposables
);
this
.
watching
=
false
;
}
...
...
@@ -366,7 +332,7 @@ class FileOutputChannel extends AbstractFileOutputChannel implements OutputChann
)
{
super
(
outputChannelIdentifier
,
modelUri
,
LOG_MIME
,
fileService
,
modelService
,
modeService
);
this
.
fileHandler
=
this
.
_register
(
new
OutputFileListener
(
this
.
file
));
this
.
fileHandler
=
this
.
_register
(
new
OutputFileListener
(
this
.
file
,
this
.
fileService
));
this
.
_register
(
this
.
fileHandler
.
onDidContentChange
(()
=>
this
.
onDidContentChange
()));
this
.
_register
(
toDisposable
(()
=>
this
.
fileHandler
.
unwatch
()));
}
...
...
@@ -458,8 +424,6 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
panelService
.
onDidPanelOpen
(
this
.
onDidPanelOpen
,
this
);
panelService
.
onDidPanelClose
(
this
.
onDidPanelClose
,
this
);
this
.
_register
(
toDisposable
(()
=>
unWatchAllFiles
()));
// Set active channel to first channel if not set
if
(
!
this
.
activeChannel
)
{
const
channels
=
this
.
getChannels
();
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录