Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
9a4d2bf4
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
9a4d2bf4
编写于
3月 17, 2016
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #4317: Compare all properties of IHTMLContentElement for equals check
上级
41f3c97a
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
101 addition
and
41 deletion
+101
-41
src/vs/base/common/htmlContent.ts
src/vs/base/common/htmlContent.ts
+60
-2
src/vs/editor/common/model/textModelWithDecorations.ts
src/vs/editor/common/model/textModelWithDecorations.ts
+2
-39
src/vs/editor/test/common/model/modelDecorations.test.ts
src/vs/editor/test/common/model/modelDecorations.test.ts
+39
-0
未找到文件。
src/vs/base/common/htmlContent.ts
浏览文件 @
9a4d2bf4
...
...
@@ -5,6 +5,11 @@
'
use strict
'
;
export
interface
IHTMLContentElementCode
{
language
:
string
;
value
:
string
;
}
export
interface
IHTMLContentElement
{
/**
* supports **bold**, __italics__, and [[actions]]
...
...
@@ -19,5 +24,58 @@ export interface IHTMLContentElement {
isText
?:
boolean
;
role
?:
string
;
markdown
?:
string
;
code
?:
{
language
:
string
;
value
:
string
;
};
}
\ No newline at end of file
code
?:
IHTMLContentElementCode
;
}
function
htmlContentElementCodeEqual
(
a
:
IHTMLContentElementCode
,
b
:
IHTMLContentElementCode
):
boolean
{
if
(
!
a
&&
!
b
)
{
return
true
;
}
if
(
!
a
||
!
b
)
{
return
false
;
}
return
(
a
.
language
===
b
.
language
&&
a
.
value
===
b
.
value
);
}
function
htmlContentElementEqual
(
a
:
IHTMLContentElement
,
b
:
IHTMLContentElement
):
boolean
{
return
(
a
.
formattedText
===
b
.
formattedText
&&
a
.
text
===
b
.
text
&&
a
.
className
===
b
.
className
&&
a
.
style
===
b
.
style
&&
a
.
customStyle
===
b
.
customStyle
&&
a
.
tagName
===
b
.
tagName
&&
a
.
isText
===
b
.
isText
&&
a
.
role
===
b
.
role
&&
a
.
markdown
===
b
.
markdown
&&
htmlContentElementCodeEqual
(
a
.
code
,
b
.
code
)
&&
htmlContentElementArrEquals
(
a
.
children
,
b
.
children
)
);
}
export
function
htmlContentElementArrEquals
(
a
:
IHTMLContentElement
[],
b
:
IHTMLContentElement
[]):
boolean
{
if
(
!
a
&&
!
b
)
{
return
true
;
}
if
(
!
a
||
!
b
)
{
return
false
;
}
let
aLen
=
a
.
length
,
bLen
=
b
.
length
;
if
(
aLen
!==
bLen
)
{
return
false
;
}
for
(
let
i
=
0
;
i
<
aLen
;
i
++
)
{
if
(
!
htmlContentElementEqual
(
a
[
i
],
b
[
i
]))
{
return
false
;
}
}
return
true
;
}
src/vs/editor/common/model/textModelWithDecorations.ts
浏览文件 @
9a4d2bf4
...
...
@@ -5,7 +5,7 @@
'
use strict
'
;
import
{
onUnexpectedError
}
from
'
vs/base/common/errors
'
;
import
{
IHTMLContentElement
}
from
'
vs/base/common/htmlContent
'
;
import
{
IHTMLContentElement
,
htmlContentElementArrEquals
}
from
'
vs/base/common/htmlContent
'
;
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
TPromise
}
from
'
vs/base/common/winjs.base
'
;
import
{
IdGenerator
}
from
'
vs/editor/common/core/idGenerator
'
;
...
...
@@ -706,43 +706,6 @@ class ModelDecorationOptions implements editorCommon.IModelDecorationOptions {
this
.
inlineClassName
=
cleanClassName
(
options
.
inlineClassName
||
strings
.
empty
);
}
private
static
_htmlContentEquals
(
a
:
IHTMLContentElement
,
b
:
IHTMLContentElement
):
boolean
{
return
(
a
.
formattedText
===
b
.
formattedText
&&
a
.
text
===
b
.
text
&&
a
.
className
===
b
.
className
&&
a
.
style
===
b
.
style
&&
a
.
customStyle
===
b
.
customStyle
&&
a
.
tagName
===
b
.
tagName
&&
a
.
isText
===
b
.
isText
&&
ModelDecorationOptions
.
_htmlContentArrEquals
(
a
.
children
,
b
.
children
)
);
}
private
static
_htmlContentArrEquals
(
a
:
IHTMLContentElement
[],
b
:
IHTMLContentElement
[]):
boolean
{
if
(
!
a
)
{
return
(
!
b
);
}
if
(
!
b
)
{
return
false
;
}
let
aLen
=
a
.
length
,
bLen
=
b
.
length
;
if
(
aLen
!==
bLen
)
{
return
false
;
}
for
(
let
i
=
0
;
i
<
aLen
;
i
++
)
{
if
(
!
ModelDecorationOptions
.
_htmlContentEquals
(
a
[
i
],
b
[
i
]))
{
return
false
;
}
}
return
true
;
}
private
static
_overviewRulerEquals
(
a
:
editorCommon
.
IModelDecorationOverviewRulerOptions
,
b
:
editorCommon
.
IModelDecorationOverviewRulerOptions
):
boolean
{
return
(
a
.
color
===
b
.
color
...
...
@@ -761,7 +724,7 @@ class ModelDecorationOptions implements editorCommon.IModelDecorationOptions {
&&
this
.
glyphMarginClassName
===
other
.
glyphMarginClassName
&&
this
.
linesDecorationsClassName
===
other
.
linesDecorationsClassName
&&
this
.
inlineClassName
===
other
.
inlineClassName
&&
ModelDecorationOptions
.
_htmlCont
entArrEquals
(
this
.
htmlMessage
,
other
.
htmlMessage
)
&&
htmlContentElem
entArrEquals
(
this
.
htmlMessage
,
other
.
htmlMessage
)
&&
ModelDecorationOptions
.
_overviewRulerEquals
(
this
.
overviewRuler
,
other
.
overviewRuler
)
);
}
...
...
src/vs/editor/test/common/model/modelDecorations.test.ts
浏览文件 @
9a4d2bf4
...
...
@@ -564,6 +564,45 @@ suite('deltaDecorations', () => {
);
});
test
(
'
issue #4317: editor.setDecorations doesn
\'
t update the hover message
'
,
()
=>
{
let
model
=
new
Model
(
'
Hello world!
'
,
Model
.
DEFAULT_CREATION_OPTIONS
,
null
);
let
ids
=
model
.
deltaDecorations
([],
[{
range
:
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
100
,
endColumn
:
1
},
options
:
{
htmlMessage
:
[{
markdown
:
'
hello1
'
}]
}
}]);
ids
=
model
.
deltaDecorations
(
ids
,
[{
range
:
{
startLineNumber
:
1
,
startColumn
:
1
,
endLineNumber
:
100
,
endColumn
:
1
},
options
:
{
htmlMessage
:
[{
markdown
:
'
hello2
'
}]
}
}]);
let
actualDecoration
=
model
.
getDecorationOptions
(
ids
[
0
]);
assert
.
equal
(
actualDecoration
.
htmlMessage
[
0
].
markdown
,
'
hello2
'
);
model
.
dispose
();
});
test
(
'
model doesn
\'
t get confused with individual tracked ranges
'
,
()
=>
{
var
model
=
new
Model
([
'
Hello world,
'
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录