Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
9cfb2fd9
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,发现更多精彩内容 >>
未验证
提交
9cfb2fd9
编写于
11月 19, 2019
作者:
A
Alexandru Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Reduce memory usage: Do not cache TextDocument.lineAt (#84940)
上级
e0a43e6f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
43 addition
and
25 deletion
+43
-25
src/vs/workbench/api/common/extHostDocumentData.ts
src/vs/workbench/api/common/extHostDocumentData.ts
+43
-25
未找到文件。
src/vs/workbench/api/common/extHostDocumentData.ts
浏览文件 @
9cfb2fd9
...
...
@@ -28,7 +28,6 @@ export class ExtHostDocumentData extends MirrorTextModel {
private
_languageId
:
string
;
private
_isDirty
:
boolean
;
private
_document
?:
vscode
.
TextDocument
;
private
_textLines
:
vscode
.
TextLine
[]
=
[];
private
_isDisposed
:
boolean
=
false
;
constructor
(
proxy
:
MainThreadDocumentsShape
,
uri
:
URI
,
lines
:
string
[],
eol
:
string
,
...
...
@@ -130,33 +129,11 @@ export class ExtHostDocumentData extends MirrorTextModel {
line
=
lineOrPosition
;
}
if
(
typeof
line
!==
'
number
'
||
line
<
0
||
line
>=
this
.
_lines
.
length
)
{
if
(
typeof
line
!==
'
number
'
||
line
<
0
||
line
>=
this
.
_lines
.
length
||
Math
.
floor
(
line
)
!==
line
)
{
throw
new
Error
(
'
Illegal value for `line`
'
);
}
let
result
=
this
.
_textLines
[
line
];
if
(
!
result
||
result
.
lineNumber
!==
line
||
result
.
text
!==
this
.
_lines
[
line
])
{
const
text
=
this
.
_lines
[
line
];
const
firstNonWhitespaceCharacterIndex
=
/^
(\s
*
)
/
.
exec
(
text
)
!
[
1
].
length
;
const
range
=
new
Range
(
line
,
0
,
line
,
text
.
length
);
const
rangeIncludingLineBreak
=
line
<
this
.
_lines
.
length
-
1
?
new
Range
(
line
,
0
,
line
+
1
,
0
)
:
range
;
result
=
Object
.
freeze
({
lineNumber
:
line
,
range
,
rangeIncludingLineBreak
,
text
,
firstNonWhitespaceCharacterIndex
,
//TODO@api, rename to 'leadingWhitespaceLength'
isEmptyOrWhitespace
:
firstNonWhitespaceCharacterIndex
===
text
.
length
});
this
.
_textLines
[
line
]
=
result
;
}
return
result
;
return
new
ExtHostDocumentLine
(
line
,
this
.
_lines
[
line
],
line
===
this
.
_lines
.
length
-
1
);
}
private
_offsetAt
(
position
:
vscode
.
Position
):
number
{
...
...
@@ -255,3 +232,44 @@ export class ExtHostDocumentData extends MirrorTextModel {
return
undefined
;
}
}
class
ExtHostDocumentLine
implements
vscode
.
TextLine
{
private
readonly
_line
:
number
;
private
readonly
_text
:
string
;
private
readonly
_isLastLine
:
boolean
;
constructor
(
line
:
number
,
text
:
string
,
isLastLine
:
boolean
)
{
this
.
_line
=
line
;
this
.
_text
=
text
;
this
.
_isLastLine
=
isLastLine
;
}
public
get
lineNumber
():
number
{
return
this
.
_line
;
}
public
get
text
():
string
{
return
this
.
_text
;
}
public
get
range
():
Range
{
return
new
Range
(
this
.
_line
,
0
,
this
.
_line
,
this
.
_text
.
length
);
}
public
get
rangeIncludingLineBreak
():
Range
{
if
(
this
.
_isLastLine
)
{
return
this
.
range
;
}
return
new
Range
(
this
.
_line
,
0
,
this
.
_line
+
1
,
0
);
}
public
get
firstNonWhitespaceCharacterIndex
():
number
{
//TODO@api, rename to 'leadingWhitespaceLength'
return
/^
(\s
*
)
/
.
exec
(
this
.
_text
)
!
[
1
].
length
;
}
public
get
isEmptyOrWhitespace
():
boolean
{
return
this
.
firstNonWhitespaceCharacterIndex
===
this
.
_text
.
length
;
}
}
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录