Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
19fd2b50
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,发现更多精彩内容 >>
未验证
提交
19fd2b50
编写于
4月 03, 2019
作者:
S
Sandeep Somavarapu
提交者:
GitHub
4月 03, 2019
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #71655 from Microsoft/ben/output-fileservice
output - use fileservice for watching
上级
10d5f630
e9795f41
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
12 addition
and
35 deletion
+12
-35
src/vs/workbench/services/output/node/outputChannelModelService.ts
...rkbench/services/output/node/outputChannelModelService.ts
+12
-35
未找到文件。
src/vs/workbench/services/output/node/outputChannelModelService.ts
浏览文件 @
19fd2b50
...
...
@@ -4,8 +4,7 @@
*--------------------------------------------------------------------------------------------*/
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
watchFolder
}
from
'
vs/base/node/watcher
'
;
import
{
dirname
,
join
}
from
'
vs/base/common/path
'
;
import
{
join
}
from
'
vs/base/common/path
'
;
import
*
as
resources
from
'
vs/base/common/resources
'
;
import
{
ITextModel
}
from
'
vs/editor/common/model
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
...
...
@@ -13,7 +12,7 @@ import { ThrottledDelayer } from 'vs/base/common/async';
import
{
IFileService
}
from
'
vs/platform/files/common/files
'
;
import
{
IModelService
}
from
'
vs/editor/common/services/modelService
'
;
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
toDisposable
,
IDisposable
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ILogService
}
from
'
vs/platform/log/common/log
'
;
import
{
IOutputChannelModel
,
AbstractFileOutputChannelModel
,
IOutputChannelModelService
,
AsbtractOutputChannelModelService
,
BufferredOutputChannel
}
from
'
vs/workbench/services/output/common/outputChannelModel
'
;
import
{
OutputAppender
}
from
'
vs/workbench/services/output/node/outputAppender
'
;
...
...
@@ -24,34 +23,13 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import
{
registerSingleton
}
from
'
vs/platform/instantiation/common/extensions
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
let
watchingOutputDir
=
false
;
let
callbacks
:
((
eventType
:
'
added
'
|
'
changed
'
|
'
deleted
'
,
path
:
string
)
=>
void
)[]
=
[];
function
watchOutputDirectory
(
outputDir
:
string
,
logService
:
ILogService
,
onChange
:
(
eventType
:
'
added
'
|
'
changed
'
|
'
deleted
'
,
path
:
string
)
=>
void
):
IDisposable
{
callbacks
.
push
(
onChange
);
if
(
!
watchingOutputDir
)
{
const
watcherDisposable
=
watchFolder
(
outputDir
,
(
eventType
,
path
)
=>
{
for
(
const
callback
of
callbacks
)
{
callback
(
eventType
,
path
);
}
},
(
error
:
string
)
=>
{
logService
.
error
(
error
);
});
watchingOutputDir
=
true
;
return
toDisposable
(()
=>
{
callbacks
=
[];
watcherDisposable
.
dispose
();
});
}
return
toDisposable
(()
=>
{
});
}
class
OutputChannelBackedByFile
extends
AbstractFileOutputChannelModel
implements
IOutputChannelModel
{
private
appender
:
OutputAppender
;
private
appendedMessage
:
string
;
private
loadingFromFileInProgress
:
boolean
;
private
resettingDelayer
:
ThrottledDelayer
<
void
>
;
private
readonly
rotatingFilePath
:
string
;
private
readonly
rotatingFilePath
:
URI
;
constructor
(
id
:
string
,
...
...
@@ -70,9 +48,15 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannelModel implement
// Use one rotating file to check for main file reset
this
.
appender
=
new
OutputAppender
(
id
,
this
.
file
.
fsPath
);
const
rotatingFilePathDirectory
=
dirname
(
this
.
file
.
fsPath
);
this
.
rotatingFilePath
=
join
(
rotatingFilePathDirectory
,
`
${
id
}
.1.log`
);
this
.
_register
(
watchOutputDirectory
(
rotatingFilePathDirectory
,
logService
,
(
eventType
,
path
)
=>
this
.
onFileChangedInOutputDirectory
(
eventType
,
path
)));
const
rotatingFilePathDirectory
=
resources
.
dirname
(
this
.
file
);
this
.
rotatingFilePath
=
resources
.
joinPath
(
rotatingFilePathDirectory
,
`
${
id
}
.1.log`
);
this
.
_register
(
fileService
.
watch
(
rotatingFilePathDirectory
));
this
.
_register
(
fileService
.
onFileChanges
(
e
=>
{
if
(
e
.
contains
(
this
.
rotatingFilePath
))
{
this
.
resettingDelayer
.
trigger
(()
=>
this
.
resetModel
());
}
}));
this
.
resettingDelayer
=
new
ThrottledDelayer
<
void
>
(
50
);
}
...
...
@@ -145,13 +129,6 @@ class OutputChannelBackedByFile extends AbstractFileOutputChannelModel implement
}
}
private
onFileChangedInOutputDirectory
(
eventType
:
'
added
'
|
'
changed
'
|
'
deleted
'
,
path
:
string
):
void
{
// Check if rotating file has changed. It changes only when the main file exceeds its limit.
if
(
this
.
rotatingFilePath
===
path
)
{
this
.
resettingDelayer
.
trigger
(()
=>
this
.
resetModel
());
}
}
private
write
(
content
:
string
):
void
{
this
.
appender
.
append
(
content
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录