Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
c9faab37
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,发现更多精彩内容 >>
提交
c9faab37
编写于
12月 20, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Use node file watcher to watch the log file
上级
52c61dc9
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
54 addition
and
12 deletion
+54
-12
src/vs/workbench/parts/output/electron-browser/outputServices.ts
...workbench/parts/output/electron-browser/outputServices.ts
+54
-12
未找到文件。
src/vs/workbench/parts/output/electron-browser/outputServices.ts
浏览文件 @
c9faab37
...
...
@@ -7,6 +7,7 @@ import * as nls from 'vs/nls';
import
*
as
paths
from
'
vs/base/common/paths
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
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
'
;
...
...
@@ -27,7 +28,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import
{
RunOnceScheduler
,
ThrottledDelayer
}
from
'
vs/base/common/async
'
;
import
{
EditOperation
}
from
'
vs/editor/common/core/editOperation
'
;
import
{
Position
}
from
'
vs/editor/common/core/position
'
;
import
{
IFileService
,
FileChangeType
}
from
'
vs/platform/files/common/files
'
;
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IPanel
}
from
'
vs/workbench/common/panel
'
;
import
{
ResourceEditorInput
}
from
'
vs/workbench/common/editor/resourceEditorInput
'
;
import
{
IEnvironmentService
}
from
'
vs/platform/environment/common/environment
'
;
...
...
@@ -66,6 +67,45 @@ 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
;
...
...
@@ -269,27 +309,27 @@ class OutputFileListener extends Disposable {
private
_onDidChange
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
readonly
onDidContentChange
:
Event
<
void
>
=
this
.
_onDidChange
.
event
;
private
watching
:
boolean
=
false
;
private
disposables
:
IDisposable
[]
=
[];
constructor
(
private
readonly
file
:
URI
,
private
fileService
:
IFileService
)
{
super
();
}
watch
():
void
{
this
.
fileService
.
watchFileChanges
(
this
.
file
);
this
.
disposables
.
push
(
this
.
fileService
.
onFileChanges
(
changes
=>
{
if
(
changes
.
contains
(
this
.
file
,
FileChangeType
.
UPDATED
))
{
this
.
_onDidChange
.
fire
();
}
}));
if
(
!
this
.
watching
)
{
this
.
disposables
.
push
(
watchFile
(
this
.
file
.
fsPath
,
()
=>
this
.
_onDidChange
.
fire
()));
this
.
watching
=
true
;
}
}
unwatch
():
void
{
this
.
fileService
.
unwatchFileChanges
(
this
.
file
);
this
.
disposables
=
dispose
(
this
.
disposables
);
if
(
this
.
watching
)
{
this
.
disposables
=
dispose
(
this
.
disposables
);
this
.
watching
=
false
;
}
}
dispose
():
void
{
...
...
@@ -312,11 +352,12 @@ class FileOutputChannel extends AbstractFileOutputChannel implements OutputChann
modelUri
:
URI
,
@
IFileService
fileService
:
IFileService
,
@
IModelService
modelService
:
IModelService
,
@
IModeService
modeService
:
IModeService
@
IModeService
modeService
:
IModeService
,
@
ILogService
logService
:
ILogService
,
)
{
super
(
outputChannelIdentifier
,
modelUri
,
fileService
,
modelService
,
modeService
);
this
.
fileHandler
=
this
.
_register
(
new
OutputFileListener
(
this
.
file
,
fileService
));
this
.
fileHandler
=
this
.
_register
(
new
OutputFileListener
(
this
.
file
));
this
.
_register
(
this
.
fileHandler
.
onDidContentChange
(()
=>
this
.
onDidContentChange
()));
this
.
_register
(
toDisposable
(()
=>
this
.
fileHandler
.
unwatch
()));
}
...
...
@@ -391,6 +432,7 @@ export class OutputService extends Disposable implements IOutputService, ITextMo
panelService
.
onDidPanelClose
(
this
.
onDidPanelClose
,
this
);
this
.
outputDir
=
paths
.
join
(
environmentService
.
logsPath
,
`output_
${
windowService
.
getCurrentWindowId
()}
_
${
toLocalISOString
(
new
Date
()).
replace
(
/-|:|
\.\d
+Z$/g
,
''
)}
`
);
this
.
_register
(
toDisposable
(()
=>
unWatchAllFiles
()));
}
provideTextContent
(
resource
:
URI
):
TPromise
<
IModel
>
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录