Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
a6376e7c
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,发现更多精彩内容 >>
提交
a6376e7c
编写于
1月 16, 2017
作者:
I
isidor
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
debug inline values: use scheduler for removal
上级
3893c043
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
48 addition
and
54 deletion
+48
-54
src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts
...h/parts/debug/electron-browser/debugEditorContribution.ts
+48
-54
未找到文件。
src/vs/workbench/parts/debug/electron-browser/debugEditorContribution.ts
浏览文件 @
a6376e7c
...
...
@@ -36,7 +36,7 @@ import { FloatingClickWidget } from 'vs/workbench/parts/preferences/browser/pref
const
HOVER_DELAY
=
300
;
const
LAUNCH_JSON_REGEX
=
/launch
\.
json$/
;
const
REMOVE_
DECORATORS_DEBOUNCE_INTERVAL
=
100
;
// If we receive a break in this interval, don't reset decorators as it causes a UI flash.
const
REMOVE_
INLINE_VALUES_DELAY
=
100
;
const
INLINE_VALUE_DECORATION_KEY
=
'
inlinevaluedecoration
'
;
const
MAX_INLINE_VALUE_LENGTH
=
50
;
// Max string length of each inline 'x = y' string. If exceeded ... is added
const
MAX_INLINE_DECORATOR_LENGTH
=
150
;
// Max string length of each inline decorator when debugging. If exceeded ... is added
...
...
@@ -53,12 +53,12 @@ export class DebugEditorContribution implements IDebugEditorContribution {
private
hoverWidget
:
DebugHoverWidget
;
private
showHoverScheduler
:
RunOnceScheduler
;
private
hideHoverScheduler
:
RunOnceScheduler
;
private
removeInlineValuesScheduler
:
RunOnceScheduler
;
private
hoverRange
:
Range
;
private
breakpointHintDecoration
:
string
[];
private
breakpointWidget
:
BreakpointWidget
;
private
breakpointWidgetVisible
:
IContextKey
<
boolean
>
;
private
removeDecorationsTimeoutId
=
0
;
private
wordToLineNumbersMap
:
Map
<
string
,
number
[]
>
;
private
configurationWidget
:
FloatingClickWidget
;
...
...
@@ -79,6 +79,7 @@ export class DebugEditorContribution implements IDebugEditorContribution {
this
.
toDispose
=
[];
this
.
showHoverScheduler
=
new
RunOnceScheduler
(()
=>
this
.
showHover
(
this
.
hoverRange
,
false
),
HOVER_DELAY
);
this
.
hideHoverScheduler
=
new
RunOnceScheduler
(()
=>
this
.
hoverWidget
.
hide
(),
HOVER_DELAY
);
this
.
removeInlineValuesScheduler
=
new
RunOnceScheduler
(()
=>
this
.
editor
.
removeDecorations
(
INLINE_VALUE_DECORATION_KEY
),
REMOVE_INLINE_VALUES_DELAY
);
this
.
registerListeners
();
this
.
breakpointWidgetVisible
=
CONTEXT_BREAKPOINT_WIDGET_VISIBLE
.
bindTo
(
contextKeyService
);
this
.
updateConfigurationWidgetVisibility
();
...
...
@@ -225,34 +226,6 @@ export class DebugEditorContribution implements IDebugEditorContribution {
}
}
private
updateInlineDecorators
(
stackFrame
:
IStackFrame
):
void
{
// Since step over, step out is a fast continue + break. Continue clears stack.
// This means we'll get a null stackFrame followed quickly by a valid stackFrame.
// Removing all decorators and adding them again causes a noticeable UI flash due to relayout and paint.
// We want to only remove inline decorations if a null stackFrame isn't followed by a valid stackFrame in a short interval.
clearTimeout
(
this
.
removeDecorationsTimeoutId
);
if
(
!
stackFrame
)
{
this
.
removeDecorationsTimeoutId
=
setTimeout
(()
=>
{
this
.
editor
.
removeDecorations
(
INLINE_VALUE_DECORATION_KEY
);
},
REMOVE_DECORATORS_DEBOUNCE_INTERVAL
);
return
;
}
const
editorModel
=
this
.
editor
.
getModel
();
if
(
!
editorModel
)
{
return
;
}
stackFrame
.
getScopes
()
// Get all top level children in the scope chain
.
then
(
scopes
=>
TPromise
.
join
(
scopes
.
map
(
scope
=>
scope
.
getChildren
())))
.
then
(
children
=>
{
const
expressions
=
children
.
reduce
((
previous
,
current
)
=>
previous
.
concat
(
current
),
[]);
const
decorations
=
this
.
createInlineValueDecorations
(
expressions
);
this
.
editor
.
setDecorations
(
INLINE_VALUE_DECORATION_KEY
,
decorations
);
});
}
private
hideHoverWidget
():
void
{
if
(
!
this
.
hideHoverScheduler
.
isScheduled
()
&&
this
.
hoverWidget
.
isVisible
())
{
this
.
hideHoverScheduler
.
schedule
();
...
...
@@ -379,7 +352,27 @@ export class DebugEditorContribution implements IDebugEditorContribution {
// Inline Decorations
private
createInlineValueDecorations
(
expressions
:
IExpression
[]):
IDecorationOptions
[]
{
private
updateInlineDecorators
(
stackFrame
:
IStackFrame
):
void
{
if
(
!
stackFrame
)
{
if
(
!
this
.
removeInlineValuesScheduler
.
isScheduled
())
{
this
.
removeInlineValuesScheduler
.
schedule
();
}
return
;
}
this
.
removeInlineValuesScheduler
.
cancel
();
stackFrame
.
getScopes
()
// Get all top level children in the scope chain
.
then
(
scopes
=>
TPromise
.
join
(
scopes
.
map
(
scope
=>
scope
.
getChildren
())))
.
then
(
children
=>
{
const
expressions
=
children
.
reduce
((
previous
,
current
)
=>
previous
.
concat
(
current
),
[]);
const
decorations
=
this
.
createAllInlineValueDecorations
(
expressions
);
this
.
editor
.
setDecorations
(
INLINE_VALUE_DECORATION_KEY
,
decorations
);
});
}
private
createAllInlineValueDecorations
(
expressions
:
IExpression
[]):
IDecorationOptions
[]
{
const
nameValueMap
=
new
Map
<
string
,
string
>
();
for
(
let
expr
of
expressions
)
{
// Put ellipses in value if its too long. Preserve last char e.g "longstr…" or {a:true, b:true, …}
...
...
@@ -417,13 +410,13 @@ export class DebugEditorContribution implements IDebugEditorContribution {
lineToNamesMap
.
forEach
((
names
,
line
)
=>
{
// Wrap with 1em unicode space for readability
const
contentText
=
'
\
u2003
'
+
names
.
map
(
name
=>
`
${
name
}
=
${
nameValueMap
.
get
(
name
)}
`
).
join
(
'
,
'
)
+
'
\
u2003
'
;
decorations
.
push
(
this
.
createDecoration
(
line
,
contentText
));
decorations
.
push
(
this
.
create
InlineValue
Decoration
(
line
,
contentText
));
});
return
decorations
;
}
private
createDecoration
(
lineNumber
:
number
,
contentText
:
string
):
IDecorationOptions
{
private
create
InlineValue
Decoration
(
lineNumber
:
number
,
contentText
:
string
):
IDecorationOptions
{
const
margin
=
'
10px
'
;
const
backgroundColor
=
'
rgba(255, 200, 0, 0.2)
'
;
const
lightForegroundColor
=
'
rgba(0, 0, 0, 0.5)
'
;
...
...
@@ -467,32 +460,33 @@ export class DebugEditorContribution implements IDebugEditorContribution {
if
(
!
this
.
wordToLineNumbersMap
)
{
this
.
wordToLineNumbersMap
=
new
Map
<
string
,
number
[]
>
();
const
model
=
this
.
editor
.
getModel
();
if
(
model
)
{
// For every word in every line, map its ranges for fast lookup
for
(
let
lineNumber
=
1
,
len
=
model
.
getLineCount
();
lineNumber
<=
len
;
++
lineNumber
)
{
const
lineContent
=
model
.
getLineContent
(
lineNumber
);
// If line is too long then skip the line
if
(
lineContent
.
length
>
MAX_TOKENIZATION_LINE_LEN
)
{
continue
;
}
// For every word in every line, map its ranges for fast lookup
for
(
let
lineNumber
=
1
,
len
=
model
.
getLineCount
();
lineNumber
<=
len
;
++
lineNumber
)
{
const
lineContent
=
model
.
getLineContent
(
lineNumber
);
// If line is too long then skip the line
if
(
lineContent
.
length
>
MAX_TOKENIZATION_LINE_LEN
)
{
continue
;
}
const
lineTokens
=
model
.
getLineTokens
(
lineNumber
);
for
(
let
token
=
lineTokens
.
firstToken
();
!!
token
;
token
=
token
.
next
())
{
const
tokenStr
=
lineContent
.
substring
(
token
.
startOffset
,
token
.
endOffset
);
const
lineTokens
=
model
.
getLineTokens
(
lineNumber
);
for
(
let
token
=
lineTokens
.
firstToken
();
!!
token
;
token
=
token
.
next
())
{
const
tokenStr
=
lineContent
.
substring
(
token
.
startOffset
,
token
.
endOffset
);
// Token is a word and not a comment
if
(
token
.
tokenType
===
StandardTokenType
.
Other
)
{
WORD_REGEXP
.
lastIndex
=
0
;
// We assume tokens will usually map 1:1 to words if they match
const
wordMatch
=
WORD_REGEXP
.
exec
(
tokenStr
);
// Token is a word and not a comment
if
(
token
.
tokenType
===
StandardTokenType
.
Other
)
{
WORD_REGEXP
.
lastIndex
=
0
;
// We assume tokens will usually map 1:1 to words if they match
const
wordMatch
=
WORD_REGEXP
.
exec
(
tokenStr
);
if
(
wordMatch
)
{
const
word
=
wordMatch
[
0
];
if
(
!
this
.
wordToLineNumbersMap
.
has
(
word
))
{
this
.
wordToLineNumbersMap
.
set
(
word
,
[]);
}
if
(
wordMatch
)
{
const
word
=
wordMatch
[
0
];
if
(
!
this
.
wordToLineNumbersMap
.
has
(
word
))
{
this
.
wordToLineNumbersMap
.
set
(
word
,
[]);
this
.
wordToLineNumbersMap
.
get
(
word
).
push
(
lineNumber
);
}
this
.
wordToLineNumbersMap
.
get
(
word
).
push
(
lineNumber
);
}
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录