Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
14057a64
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,发现更多精彩内容 >>
提交
14057a64
编写于
12月 18, 2017
作者:
S
Sandeep Somavarapu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
#40196 Write into model directly when a message is appended
上级
c16d7a3c
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
125 addition
and
88 deletion
+125
-88
src/typings/spdlog.d.ts
src/typings/spdlog.d.ts
+3
-0
src/vs/workbench/parts/output/electron-browser/outputServices.ts
...workbench/parts/output/electron-browser/outputServices.ts
+122
-88
未找到文件。
src/typings/spdlog.d.ts
浏览文件 @
14057a64
...
...
@@ -29,6 +29,9 @@ declare module 'spdlog' {
critical
(
message
:
string
);
setLevel
(
level
:
number
);
clearFormatters
();
/**
* A synchronous operation to flush the contents into file
*/
flush
():
void
;
drop
():
void
;
}
...
...
src/vs/workbench/parts/output/electron-browser/outputServices.ts
浏览文件 @
14057a64
...
...
@@ -35,7 +35,7 @@ import { toLocalISOString } from 'vs/base/common/date';
const
OUTPUT_ACTIVE_CHANNEL_KEY
=
'
output.activechannel
'
;
class
OutputFile
Handl
er
extends
Disposable
{
class
OutputFile
Listen
er
extends
Disposable
{
private
_onDidChange
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
readonly
onDidContentChange
:
Event
<
void
>
=
this
.
_onDidChange
.
event
;
...
...
@@ -58,11 +58,6 @@ class OutputFileHandler extends Disposable {
}));
}
loadContent
(
from
:
number
):
TPromise
<
string
>
{
return
this
.
fileService
.
resolveContent
(
this
.
file
)
.
then
(({
value
})
=>
value
.
substring
(
from
));
}
unwatch
():
void
{
this
.
fileService
.
unwatchFileChanges
(
this
.
file
);
this
.
disposables
=
dispose
(
this
.
disposables
);
...
...
@@ -76,44 +71,34 @@ class OutputFileHandler extends Disposable {
interface
OutputChannel
extends
IOutputChannel
{
readonly
onDispose
:
Event
<
void
>
;
resolve
():
TPromise
<
string
>
;
createModel
():
TPromise
<
IModel
>
;
}
class
FileOutputChannel
extends
Disposable
implements
OutputChannel
{
abstract
class
AbstractOutputChannel
extends
Disposable
{
scrollLock
:
boolean
=
false
;
protected
_onDispose
:
Emitter
<
void
>
=
new
Emitter
<
void
>
();
readonly
onDispose
:
Event
<
void
>
=
this
.
_onDispose
.
event
;
scrollLock
:
boolean
=
false
;
protected
readonly
file
:
URI
;
private
readonly
fileHandler
:
OutputFileHandler
;
private
updateInProgress
:
boolean
=
false
;
private
modelUpdater
:
RunOnceScheduler
;
private
startOffset
:
number
;
private
endOffset
:
number
;
protected
startOffset
:
number
=
0
;
protected
endOffset
:
number
=
0
;
protected
modelUpdater
:
RunOnceScheduler
;
constructor
(
private
readonly
outputChannelIdentifier
:
IOutputChannelIdentifier
,
@
IFileService
protected
fileService
:
IFileService
,
@
IModelService
private
modelService
:
IModelService
,
@
IPanelService
private
panelService
:
IPanelService
protected
readonly
outputChannelIdentifier
:
IOutputChannelIdentifier
,
protected
fileService
:
IFileService
,
private
modelService
:
IModelService
,
private
modeService
:
IModeService
,
private
panelService
:
IPanelService
)
{
super
();
this
.
file
=
outputChannelIdentifier
.
file
;
this
.
startOffset
=
0
;
this
.
endOffset
=
0
;
this
.
modelUpdater
=
new
RunOnceScheduler
(()
=>
this
.
doUpdate
(),
300
);
this
.
modelUpdater
=
new
RunOnceScheduler
(()
=>
this
.
updateModel
(),
300
);
this
.
_register
(
toDisposable
(()
=>
this
.
modelUpdater
.
cancel
()));
this
.
fileHandler
=
this
.
_register
(
new
OutputFileHandler
(
this
.
file
,
this
.
fileService
));
this
.
_register
(
this
.
fileHandler
.
onDidContentChange
(()
=>
this
.
onDidContentChange
()));
this
.
_register
(
toDisposable
(()
=>
this
.
fileHandler
.
unwatch
()));
this
.
_register
(
this
.
modelService
.
onModelAdded
(
this
.
onModelAdded
,
this
));
this
.
_register
(
this
.
modelService
.
onModelRemoved
(
this
.
onModelRemoved
,
this
));
}
get
id
():
string
{
...
...
@@ -124,11 +109,10 @@ class FileOutputChannel extends Disposable implements OutputChannel {
return
this
.
outputChannelIdentifier
.
label
;
}
append
(
message
:
string
):
void
{
throw
new
Error
(
'
Not supported
'
);
}
clear
():
void
{
if
(
this
.
modelUpdater
.
isScheduled
())
{
this
.
modelUpdater
.
cancel
();
}
this
.
startOffset
=
this
.
endOffset
;
const
model
=
this
.
getModel
();
if
(
model
)
{
...
...
@@ -136,36 +120,79 @@ class FileOutputChannel extends Disposable implements OutputChannel {
}
}
resolve
():
TPromise
<
string
>
{
return
this
.
fileHandler
.
loadContent
(
this
.
startOffset
);
createModel
():
TPromise
<
IModel
>
{
return
this
.
fileService
.
resolveContent
(
this
.
file
,
{
position
:
this
.
startOffset
})
.
then
(
content
=>
{
const
model
=
this
.
modelService
.
createModel
(
content
.
value
,
this
.
modeService
.
getOrCreateMode
(
OUTPUT_MIME
),
URI
.
from
({
scheme
:
OUTPUT_SCHEME
,
path
:
this
.
id
}));
this
.
endOffset
=
this
.
startOffset
+
new
Buffer
(
model
.
getValueLength
()).
byteLength
;
this
.
onModelCreated
(
model
);
const
disposables
:
IDisposable
[]
=
[];
disposables
.
push
(
model
.
onWillDispose
(()
=>
{
this
.
onModelWillDispose
(
model
);
dispose
(
disposables
);
}));
return
model
;
});
}
private
onModelAdded
(
model
:
IModel
):
void
{
if
(
model
.
uri
.
fsPath
===
this
.
id
)
{
this
.
endOffset
=
this
.
startOffset
+
new
Buffer
(
model
.
getValueLength
()).
byteLength
;
this
.
fileHandler
.
watch
();
protected
appendContent
(
content
:
string
):
void
{
const
model
=
this
.
getModel
();
if
(
model
&&
content
)
{
const
lastLine
=
model
.
getLineCount
();
const
lastLineMaxColumn
=
model
.
getLineMaxColumn
(
lastLine
);
model
.
applyEdits
([
EditOperation
.
insert
(
new
Position
(
lastLine
,
lastLineMaxColumn
),
content
)]);
this
.
endOffset
=
this
.
endOffset
+
new
Buffer
(
content
).
byteLength
;
if
(
!
this
.
scrollLock
)
{
(
<
OutputPanel
>
this
.
panelService
.
getActivePanel
()).
revealLastLine
();
}
}
}
private
onModelRemoved
(
model
:
IModel
):
void
{
if
(
model
.
uri
.
fsPath
===
this
.
id
)
{
this
.
fileHandler
.
unwatch
();
}
protected
getModel
():
IModel
{
const
model
=
this
.
modelService
.
getModel
(
URI
.
from
({
scheme
:
OUTPUT_SCHEME
,
path
:
this
.
id
}));
return
model
&&
!
model
.
isDisposed
()
?
model
:
null
;
}
private
onDidContentChange
():
void
{
if
(
!
this
.
updateInProgress
)
{
this
.
updateInProgress
=
true
;
this
.
modelUpdater
.
schedule
();
}
protected
onModelCreated
(
model
:
IModel
)
{
}
protected
onModelWillDispose
(
model
:
IModel
)
{
}
protected
updateModel
()
{
}
dispose
():
void
{
this
.
_onDispose
.
fire
();
super
.
dispose
();
}
}
class
FileOutputChannel
extends
AbstractOutputChannel
implements
OutputChannel
{
private
readonly
fileHandler
:
OutputFileListener
;
private
updateInProgress
:
boolean
=
false
;
constructor
(
outputChannelIdentifier
:
IOutputChannelIdentifier
,
@
IFileService
fileService
:
IFileService
,
@
IModelService
modelService
:
IModelService
,
@
IModeService
modeService
:
IModeService
,
@
IPanelService
panelService
:
IPanelService
)
{
super
(
outputChannelIdentifier
,
fileService
,
modelService
,
modeService
,
panelService
);
private
doUpdate
():
void
{
this
.
fileHandler
=
this
.
_register
(
new
OutputFileListener
(
this
.
file
,
fileService
));
this
.
_register
(
this
.
fileHandler
.
onDidContentChange
(()
=>
this
.
onDidContentChange
()));
this
.
_register
(
toDisposable
(()
=>
this
.
fileHandler
.
unwatch
()));
}
append
(
message
:
string
):
void
{
throw
new
Error
(
'
Not supported
'
);
}
protected
updateModel
():
void
{
let
model
=
this
.
getModel
();
if
(
model
)
{
this
.
file
Handler
.
loadContent
(
this
.
endOffset
)
this
.
file
Service
.
resolveContent
(
this
.
file
,
{
position
:
this
.
endOffset
}
)
.
then
(
content
=>
{
this
.
appendContent
(
content
);
this
.
appendContent
(
content
.
value
);
this
.
updateInProgress
=
false
;
},
()
=>
this
.
updateInProgress
=
false
);
}
else
{
...
...
@@ -173,59 +200,69 @@ class FileOutputChannel extends Disposable implements OutputChannel {
}
}
private
appendContent
(
content
:
string
):
void
{
const
model
=
this
.
getModel
();
if
(
model
&&
content
)
{
const
lastLine
=
model
.
getLineCount
();
const
lastLineMaxColumn
=
model
.
getLineMaxColumn
(
lastLine
);
model
.
applyEdits
([
EditOperation
.
insert
(
new
Position
(
lastLine
,
lastLineMaxColumn
),
content
)]);
this
.
endOffset
=
this
.
endOffset
+
new
Buffer
(
content
).
byteLength
;
if
(
!
this
.
scrollLock
)
{
(
<
OutputPanel
>
this
.
panelService
.
getActivePanel
()).
revealLastLine
();
}
}
protected
onModelCreated
(
model
:
IModel
):
void
{
this
.
fileHandler
.
watch
();
}
protected
getModel
():
IModel
{
const
model
=
this
.
modelService
.
getModel
(
URI
.
from
({
scheme
:
OUTPUT_SCHEME
,
path
:
this
.
id
}));
return
model
&&
!
model
.
isDisposed
()
?
model
:
null
;
protected
onModelWillDispose
(
model
:
IModel
):
void
{
this
.
fileHandler
.
unwatch
();
}
dispose
():
void
{
this
.
_onDispose
.
fire
();
super
.
dispose
();
private
onDidContentChange
():
void
{
if
(
!
this
.
updateInProgress
)
{
this
.
updateInProgress
=
true
;
this
.
modelUpdater
.
schedule
();
}
}
}
class
AppendableFileOut
outChannel
extends
File
OutputChannel
implements
OutputChannel
{
class
AppendableFileOut
putChannel
extends
Abstract
OutputChannel
implements
OutputChannel
{
private
outputWriter
:
RotatingLogger
;
private
flushScheduler
:
RunOnceScheduler
;
private
appendedMessage
=
''
;
constructor
(
outputChannelIdentifier
:
IOutputChannelIdentifier
,
@
IFileService
fileService
:
IFileService
,
@
IModelService
modelService
:
IModelService
,
@
IPanelService
panelService
:
IPanelService
,
@
IModeService
modeService
:
IModeService
,
@
IPanelService
panelService
:
IPanelService
)
{
super
(
outputChannelIdentifier
,
fileService
,
modelService
,
panelService
);
super
(
outputChannelIdentifier
,
fileService
,
modelService
,
modeService
,
panelService
);
this
.
outputWriter
=
new
RotatingLogger
(
this
.
id
,
this
.
file
.
fsPath
,
1024
*
1024
*
5
,
1
);
this
.
outputWriter
.
clearFormatters
();
this
.
flushScheduler
=
new
RunOnceScheduler
(()
=>
this
.
outputWriter
.
flush
(),
300
);
this
.
_register
(
toDisposable
(()
=>
this
.
flushScheduler
.
cancel
()));
this
.
_register
(
modelService
.
onModelAdded
(
model
=>
{
if
(
model
.
uri
.
fsPath
===
this
.
id
&&
!
this
.
flushScheduler
.
isScheduled
())
{
this
.
flushScheduler
.
schedule
();
}
}));
}
append
(
message
:
string
):
void
{
this
.
outputWriter
.
critical
(
message
);
if
(
this
.
getModel
()
&&
!
this
.
flushScheduler
.
isScheduled
())
{
this
.
flushScheduler
.
schedule
();
const
model
=
this
.
getModel
();
if
(
model
)
{
this
.
appendedMessage
+=
message
;
if
(
!
this
.
modelUpdater
.
isScheduled
())
{
this
.
modelUpdater
.
schedule
();
}
}
}
clear
():
void
{
super
.
clear
();
this
.
appendedMessage
=
''
;
}
createModel
():
TPromise
<
IModel
>
{
this
.
outputWriter
.
flush
();
this
.
appendedMessage
=
''
;
return
super
.
createModel
();
}
protected
updateModel
():
void
{
let
model
=
this
.
getModel
();
if
(
model
)
{
if
(
this
.
appendedMessage
)
{
this
.
appendContent
(
this
.
appendedMessage
);
this
.
appendedMessage
=
''
;
}
}
}
}
...
...
@@ -247,8 +284,6 @@ export class OutputService implements IOutputService, ITextModelContentProvider
@
IInstantiationService
private
instantiationService
:
IInstantiationService
,
@
IPanelService
private
panelService
:
IPanelService
,
@
IWorkspaceContextService
contextService
:
IWorkspaceContextService
,
@
IModelService
private
modelService
:
IModelService
,
@
IModeService
private
modeService
:
IModeService
,
@
ITextModelService
textModelResolverService
:
ITextModelService
,
@
IWorkbenchEditorService
private
editorService
:
IWorkbenchEditorService
,
@
IEnvironmentService
private
environmentService
:
IEnvironmentService
...
...
@@ -268,8 +303,7 @@ export class OutputService implements IOutputService, ITextModelContentProvider
provideTextContent
(
resource
:
URI
):
TPromise
<
IModel
>
{
const
channel
=
<
OutputChannel
>
this
.
getChannel
(
resource
.
fsPath
);
return
channel
.
resolve
()
.
then
(
content
=>
this
.
modelService
.
createModel
(
content
,
this
.
modeService
.
getOrCreateMode
(
OUTPUT_MIME
),
resource
));
return
channel
.
createModel
();
}
showChannel
(
id
:
string
,
preserveFocus
?:
boolean
):
TPromise
<
void
>
{
...
...
@@ -332,7 +366,7 @@ export class OutputService implements IOutputService, ITextModelContentProvider
}
const
sessionId
=
toLocalISOString
(
new
Date
()).
replace
(
/-|:|
\.\d
+Z$/g
,
''
);
const
file
=
URI
.
file
(
paths
.
join
(
this
.
environmentService
.
logsPath
,
'
outputs
'
,
`
${
id
}
.
${
sessionId
}
.log`
));
return
this
.
instantiationService
.
createInstance
(
AppendableFileOut
o
utChannel
,
{
id
,
label
:
channelData
?
channelData
.
label
:
''
,
file
});
return
this
.
instantiationService
.
createInstance
(
AppendableFileOut
p
utChannel
,
{
id
,
label
:
channelData
?
channelData
.
label
:
''
,
file
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录