Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
d238ba5b
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,发现更多精彩内容 >>
提交
d238ba5b
编写于
12月 22, 2017
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove unused code
上级
7b8f3088
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
18 addition
and
231 deletion
+18
-231
src/vs/editor/common/model/modelLine.ts
src/vs/editor/common/model/modelLine.ts
+0
-121
src/vs/editor/common/model/textBuffer.ts
src/vs/editor/common/model/textBuffer.ts
+6
-6
src/vs/editor/common/model/textModel.ts
src/vs/editor/common/model/textModel.ts
+0
-8
src/vs/editor/test/common/model/model.line.test.ts
src/vs/editor/test/common/model/model.line.test.ts
+12
-96
未找到文件。
src/vs/editor/common/model/modelLine.ts
浏览文件 @
d238ba5b
...
...
@@ -46,127 +46,6 @@ export function computeIndentLevel(line: string, tabSize: number): number {
return
indent
;
}
export
interface
IModelLine
{
readonly
text
:
string
;
// --- editing
applyEdits
(
edits
:
ILineEdit
[]):
number
;
append
(
other
:
IModelLine
):
void
;
split
(
splitColumn
:
number
):
IModelLine
;
}
export
abstract
class
AbstractModelLine
{
constructor
()
{
}
///
public
abstract
get
text
():
string
;
protected
abstract
_setText
(
text
:
string
):
void
;
protected
abstract
_createModelLine
(
text
:
string
):
IModelLine
;
///
public
applyEdits
(
edits
:
ILineEdit
[]):
number
{
let
deltaColumn
=
0
;
let
resultText
=
this
.
text
;
for
(
let
i
=
0
,
len
=
edits
.
length
;
i
<
len
;
i
++
)
{
let
edit
=
edits
[
i
];
// console.log();
// console.log('=============================');
// console.log('EDIT #' + i + ' [ ' + edit.startColumn + ' -> ' + edit.endColumn + ' ] : <<<' + edit.text + '>>>');
// console.log('deltaColumn: ' + deltaColumn);
let
startColumn
=
deltaColumn
+
edit
.
startColumn
;
let
endColumn
=
deltaColumn
+
edit
.
endColumn
;
let
deletingCnt
=
endColumn
-
startColumn
;
let
insertingCnt
=
edit
.
text
.
length
;
// Perform the edit & update `deltaColumn`
resultText
=
resultText
.
substring
(
0
,
startColumn
-
1
)
+
edit
.
text
+
resultText
.
substring
(
endColumn
-
1
);
deltaColumn
+=
insertingCnt
-
deletingCnt
;
}
// Save the resulting text
this
.
_setText
(
resultText
);
return
deltaColumn
;
}
public
split
(
splitColumn
:
number
):
IModelLine
{
const
myText
=
this
.
text
.
substring
(
0
,
splitColumn
-
1
);
const
otherText
=
this
.
text
.
substring
(
splitColumn
-
1
);
this
.
_setText
(
myText
);
return
this
.
_createModelLine
(
otherText
);
}
public
append
(
other
:
IModelLine
):
void
{
this
.
_setText
(
this
.
text
+
other
.
text
);
}
}
export
class
ModelLine
extends
AbstractModelLine
implements
IModelLine
{
private
_text
:
string
;
public
get
text
():
string
{
return
this
.
_text
;
}
constructor
(
text
:
string
)
{
super
();
this
.
_setText
(
text
);
}
protected
_createModelLine
(
text
:
string
):
IModelLine
{
return
new
ModelLine
(
text
);
}
public
split
(
splitColumn
:
number
):
IModelLine
{
return
super
.
split
(
splitColumn
);
}
public
append
(
other
:
IModelLine
):
void
{
super
.
append
(
other
);
}
protected
_setText
(
text
:
string
):
void
{
this
.
_text
=
text
;
}
}
/**
* A model line that cannot store any tokenization state.
* It has no fields except the text.
*/
export
class
MinimalModelLine
extends
AbstractModelLine
implements
IModelLine
{
private
_text
:
string
;
public
get
text
():
string
{
return
this
.
_text
;
}
constructor
(
text
:
string
)
{
super
();
this
.
_setText
(
text
);
}
protected
_createModelLine
(
text
:
string
):
IModelLine
{
return
new
MinimalModelLine
(
text
);
}
public
split
(
splitColumn
:
number
):
IModelLine
{
return
super
.
split
(
splitColumn
);
}
public
append
(
other
:
IModelLine
):
void
{
super
.
append
(
other
);
}
protected
_setText
(
text
:
string
):
void
{
this
.
_text
=
text
;
}
}
function
getDefaultMetadata
(
topLevelLanguageId
:
LanguageId
):
number
{
return
(
(
topLevelLanguageId
<<
MetadataConsts
.
LANGUAGEID_OFFSET
)
...
...
src/vs/editor/common/model/textBuffer.ts
浏览文件 @
d238ba5b
...
...
@@ -500,7 +500,7 @@ export class TextBuffer {
}
// this._invalidateLine(currentLineNumber - 1); //TODO@TextBuffer
this
.
_lines
[
currentLineNumber
-
1
]
=
applyLineEdits
2
(
this
.
_lines
[
currentLineNumber
-
1
]
=
applyLineEdits
(
this
.
_lines
[
currentLineNumber
-
1
],
lineEditsQueue
.
slice
(
currentLineNumberStart
,
i
)
);
...
...
@@ -514,7 +514,7 @@ export class TextBuffer {
}
// this._invalidateLine(currentLineNumber - 1); //TODO@TextBuffer
this
.
_lines
[
currentLineNumber
-
1
]
=
applyLineEdits
2
(
this
.
_lines
[
currentLineNumber
-
1
]
=
applyLineEdits
(
this
.
_lines
[
currentLineNumber
-
1
],
lineEditsQueue
.
slice
(
currentLineNumberStart
,
lineEditsQueue
.
length
)
);
...
...
@@ -570,7 +570,7 @@ export class TextBuffer {
const
spliceStartLineNumber
=
startLineNumber
+
editingLinesCnt
;
const
[
t1
,
t2
]
=
split
(
this
.
_lines
[
endLineNumber
-
1
],
endColumn
);
const
[
t1
,
t2
]
=
split
Line
(
this
.
_lines
[
endLineNumber
-
1
],
endColumn
);
this
.
_lines
[
endLineNumber
-
1
]
=
t1
;
const
endLineRemains
=
t2
;
// this._invalidateLine(spliceStartLineNumber - 1); //TODO@TextBuffer
...
...
@@ -606,7 +606,7 @@ export class TextBuffer {
}
// Split last line
const
[
t1
,
t2
]
=
split
(
this
.
_lines
[
spliceLineNumber
-
1
],
spliceColumn
);
const
[
t1
,
t2
]
=
split
Line
(
this
.
_lines
[
spliceLineNumber
-
1
],
spliceColumn
);
this
.
_lines
[
spliceLineNumber
-
1
]
=
t1
;
const
leftoverLine
=
t2
;
this
.
_lineStarts
.
changeValue
(
spliceLineNumber
-
1
,
this
.
_lines
[
spliceLineNumber
-
1
].
length
+
this
.
_EOL
.
length
);
...
...
@@ -718,7 +718,7 @@ export class TextBuffer {
//#endregion
}
function
applyLineEdits2
(
text
:
string
,
edits
:
ILineEdit
[]):
string
{
export
function
applyLineEdits
(
text
:
string
,
edits
:
ILineEdit
[]):
string
{
let
deltaColumn
=
0
;
let
resultText
=
text
;
...
...
@@ -744,7 +744,7 @@ function applyLineEdits2(text: string, edits: ILineEdit[]): string {
return
resultText
;
}
function
split
(
text
:
string
,
splitColumn
:
number
):
[
string
,
string
]
{
export
function
splitLine
(
text
:
string
,
splitColumn
:
number
):
[
string
,
string
]
{
const
myText
=
text
.
substring
(
0
,
splitColumn
-
1
);
const
otherText
=
text
.
substring
(
splitColumn
-
1
);
...
...
src/vs/editor/common/model/textModel.ts
浏览文件 @
d238ba5b
...
...
@@ -10,7 +10,6 @@ import { Position, IPosition } from 'vs/editor/common/core/position';
import
{
Range
,
IRange
}
from
'
vs/editor/common/core/range
'
;
import
{
Selection
}
from
'
vs/editor/common/core/selection
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
ModelLine
,
IModelLine
,
MinimalModelLine
}
from
'
vs/editor/common/model/modelLine
'
;
import
{
guessIndentation
,
IndentationGuesserTextBufferTarget
,
IndentationGuesserStringArrayTarget
}
from
'
vs/editor/common/model/indentationGuesser
'
;
import
{
EDITOR_MODEL_DEFAULTS
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
TextModelSearch
,
SearchParams
}
from
'
vs/editor/common/model/textModelSearch
'
;
...
...
@@ -123,13 +122,6 @@ export class TextModel extends Disposable implements editorCommon.ITextModel {
this
.
_isDisposing
=
false
;
}
protected
_createModelLine
(
text
:
string
):
IModelLine
{
if
(
this
.
_isTooLargeForTokenization
)
{
return
new
MinimalModelLine
(
text
);
}
return
new
ModelLine
(
text
);
}
protected
_assertNotDisposed
():
void
{
if
(
this
.
_isDisposed
)
{
throw
new
Error
(
'
Model is disposed!
'
);
...
...
src/vs/editor/test/common/model/model.line.test.ts
浏览文件 @
d238ba5b
...
...
@@ -6,13 +6,14 @@
import
*
as
assert
from
'
assert
'
;
import
{
LineTokens
}
from
'
vs/editor/common/core/lineTokens
'
;
import
{
ModelLine
,
ILineEdit
,
computeIndentLevel
}
from
'
vs/editor/common/model/modelLine
'
;
import
{
ILineEdit
,
computeIndentLevel
}
from
'
vs/editor/common/model/modelLine
'
;
import
{
LanguageIdentifier
,
MetadataConsts
}
from
'
vs/editor/common/modes
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ViewLineToken
,
ViewLineTokenFactory
}
from
'
vs/editor/test/common/core/viewLineToken
'
;
import
{
EditableTextModel
}
from
'
vs/editor/common/model/editableTextModel
'
;
import
{
TextModel
}
from
'
vs/editor/common/model/textModel
'
;
import
{
RawTextSource
}
from
'
vs/editor/common/model/textSource
'
;
import
{
applyLineEdits
,
splitLine
}
from
'
vs/editor/common/model/textBuffer
'
;
function
assertLineTokens
(
__actual
:
LineTokens
,
_expected
:
TestToken
[]):
void
{
let
tmp
=
TestToken
.
toTokens
(
_expected
);
...
...
@@ -66,9 +67,8 @@ suite('ModelLine - getIndentLevel', () => {
suite
(
'
Editor Model - modelLine.applyEdits text
'
,
()
=>
{
function
testEdits
(
initial
:
string
,
edits
:
ILineEdit
[],
expected
:
string
):
void
{
var
line
=
new
ModelLine
(
initial
);
line
.
applyEdits
(
edits
);
assert
.
equal
(
line
.
text
,
expected
);
const
actual
=
applyLineEdits
(
initial
,
edits
);
assert
.
equal
(
actual
,
expected
);
}
function
editOp
(
startColumn
:
number
,
endColumn
:
number
,
text
:
string
):
ILineEdit
{
...
...
@@ -212,10 +212,9 @@ suite('Editor Model - modelLine.applyEdits text', () => {
suite
(
'
Editor Model - modelLine.split text
'
,
()
=>
{
function
testLineSplit
(
initial
:
string
,
splitColumn
:
number
,
expected1
:
string
,
expected2
:
string
):
void
{
var
line
=
new
ModelLine
(
initial
);
var
newLine
=
line
.
split
(
splitColumn
);
assert
.
equal
(
line
.
text
,
expected1
);
assert
.
equal
(
newLine
.
text
,
expected2
);
const
[
actual1
,
actual2
]
=
splitLine
(
initial
,
splitColumn
);
assert
.
equal
(
actual1
,
expected1
);
assert
.
equal
(
actual2
,
expected2
);
}
test
(
'
split at the beginning
'
,
()
=>
{
...
...
@@ -246,40 +245,6 @@ suite('Editor Model - modelLine.split text', () => {
});
});
suite
(
'
Editor Model - modelLine.append text
'
,
()
=>
{
function
testLineAppend
(
a
:
string
,
b
:
string
,
expected
:
string
):
void
{
var
line1
=
new
ModelLine
(
a
);
var
line2
=
new
ModelLine
(
b
);
line1
.
append
(
line2
);
assert
.
equal
(
line1
.
text
,
expected
);
}
test
(
'
append at the beginning
'
,
()
=>
{
testLineAppend
(
''
,
'
qwerty
'
,
'
qwerty
'
);
});
test
(
'
append at the end
'
,
()
=>
{
testLineAppend
(
'
qwerty
'
,
''
,
'
qwerty
'
);
});
test
(
'
append in the middle
'
,
()
=>
{
testLineAppend
(
'
qw
'
,
'
erty
'
,
'
qwerty
'
);
});
});
class
TestToken
{
public
readonly
startOffset
:
number
;
public
readonly
color
:
number
;
...
...
@@ -1418,11 +1383,8 @@ suite('ModelLinesTokens', () => {
suite
(
'
Editor Model - modelLine.applyEdits
'
,
()
=>
{
function
testLineEdit
(
initialText
:
string
,
edits
:
ILineEdit
[],
expectedText
:
string
):
void
{
let
line
=
new
ModelLine
(
initialText
);
line
.
applyEdits
(
edits
);
assert
.
equal
(
line
.
text
,
expectedText
,
'
text
'
);
const
actual
=
applyLineEdits
(
initialText
,
edits
);
assert
.
equal
(
actual
,
expectedText
,
'
text
'
);
}
test
(
'
insertion: updates markers 1
'
,
()
=>
{
...
...
@@ -1773,12 +1735,10 @@ suite('Editor Model - modelLine.applyEdits', () => {
suite
(
'
Editor Model - modelLine.split
'
,
()
=>
{
function
testLineSplit
(
initialText
:
string
,
splitColumn
:
number
,
forceMoveMarkers
:
boolean
,
expectedText1
:
string
,
expectedText2
:
string
):
void
{
let
line
=
new
ModelLine
(
initialText
);
let
otherLine
=
line
.
split
(
splitColumn
);
const
[
l1
,
l2
]
=
splitLine
(
initialText
,
splitColumn
);
assert
.
equal
(
l
ine
.
text
,
expectedText1
,
'
text
'
);
assert
.
equal
(
otherLine
.
text
,
expectedText2
,
'
text
'
);
assert
.
equal
(
l
1
,
expectedText1
,
'
text
'
);
assert
.
equal
(
l2
,
expectedText2
,
'
text
'
);
}
test
(
'
split at the beginning
'
,
()
=>
{
...
...
@@ -1851,47 +1811,3 @@ suite('Editor Model - modelLine.split', () => {
);
});
});
suite
(
'
Editor Model - modelLine.append
'
,
()
=>
{
function
testLinePrependMarkers
(
aText
:
string
,
bText
:
string
,
expectedText
:
string
):
void
{
let
a
=
new
ModelLine
(
aText
);
let
b
=
new
ModelLine
(
bText
);
a
.
append
(
b
);
assert
.
equal
(
a
.
text
,
expectedText
,
'
text
'
);
}
test
(
'
append to an empty
'
,
()
=>
{
testLinePrependMarkers
(
'
abcd efgh
'
,
''
,
'
abcd efgh
'
,
);
});
test
(
'
append an empty
'
,
()
=>
{
testLinePrependMarkers
(
''
,
'
abcd efgh
'
,
'
abcd efgh
'
,
);
});
test
(
'
append 1
'
,
()
=>
{
testLinePrependMarkers
(
'
abcd
'
,
'
efgh
'
,
'
abcd efgh
'
,
);
});
test
(
'
append 2
'
,
()
=>
{
testLinePrependMarkers
(
'
abcd e
'
,
'
fgh
'
,
'
abcd efgh
'
,
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录