Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
10ca8670
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,发现更多精彩内容 >>
提交
10ca8670
编写于
5月 03, 2018
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixes #42751
上级
fc8b4c0d
变更
2
显示空白变更内容
内联
并排
Showing
2 changed file
with
31 addition
and
10 deletion
+31
-10
src/vs/editor/common/diff/diffComputer.ts
src/vs/editor/common/diff/diffComputer.ts
+10
-9
src/vs/editor/test/common/diff/diffComputer.test.ts
src/vs/editor/test/common/diff/diffComputer.test.ts
+21
-1
未找到文件。
src/vs/editor/common/diff/diffComputer.ts
浏览文件 @
10ca8670
...
...
@@ -74,16 +74,17 @@ class LineMarkerSequence implements ISequence {
return
r
+
2
;
}
public
getCharSequence
(
startIndex
:
number
,
endIndex
:
number
):
CharSequence
{
public
getCharSequence
(
s
houldIgnoreTrimWhitespace
:
boolean
,
s
tartIndex
:
number
,
endIndex
:
number
):
CharSequence
{
let
charCodes
:
number
[]
=
[];
let
lineNumbers
:
number
[]
=
[];
let
columns
:
number
[]
=
[];
let
len
=
0
;
for
(
let
index
=
startIndex
;
index
<=
endIndex
;
index
++
)
{
const
startColumn
=
this
.
_startColumns
[
index
];
const
endColumn
=
this
.
_endColumns
[
index
];
const
lineContent
=
this
.
_lines
[
index
];
const
startColumn
=
(
shouldIgnoreTrimWhitespace
?
this
.
_startColumns
[
index
]
:
1
);
const
endColumn
=
(
shouldIgnoreTrimWhitespace
?
this
.
_endColumns
[
index
]
:
lineContent
.
length
+
1
);
for
(
let
col
=
startColumn
;
col
<
endColumn
;
col
++
)
{
charCodes
[
len
]
=
this
.
_lines
[
index
]
.
charCodeAt
(
col
-
1
);
charCodes
[
len
]
=
lineContent
.
charCodeAt
(
col
-
1
);
lineNumbers
[
len
]
=
index
+
1
;
columns
[
len
]
=
col
;
len
++
;
...
...
@@ -254,7 +255,7 @@ class LineChange implements ILineChange {
this
.
charChanges
=
charChanges
;
}
public
static
createFromDiffResult
(
diffChange
:
IDiffChange
,
originalLineSequence
:
LineMarkerSequence
,
modifiedLineSequence
:
LineMarkerSequence
,
continueProcessingPredicate
:
()
=>
boolean
,
shouldPostProcessCharChanges
:
boolean
):
LineChange
{
public
static
createFromDiffResult
(
shouldIgnoreTrimWhitespace
:
boolean
,
diffChange
:
IDiffChange
,
originalLineSequence
:
LineMarkerSequence
,
modifiedLineSequence
:
LineMarkerSequence
,
continueProcessingPredicate
:
()
=>
boolean
,
shouldPostProcessCharChanges
:
boolean
):
LineChange
{
let
originalStartLineNumber
:
number
;
let
originalEndLineNumber
:
number
;
let
modifiedStartLineNumber
:
number
;
...
...
@@ -278,8 +279,8 @@ class LineChange implements ILineChange {
}
if
(
diffChange
.
originalLength
!==
0
&&
diffChange
.
modifiedLength
!==
0
&&
continueProcessingPredicate
())
{
const
originalCharSequence
=
originalLineSequence
.
getCharSequence
(
diffChange
.
originalStart
,
diffChange
.
originalStart
+
diffChange
.
originalLength
-
1
);
const
modifiedCharSequence
=
modifiedLineSequence
.
getCharSequence
(
diffChange
.
modifiedStart
,
diffChange
.
modifiedStart
+
diffChange
.
modifiedLength
-
1
);
const
originalCharSequence
=
originalLineSequence
.
getCharSequence
(
shouldIgnoreTrimWhitespace
,
diffChange
.
originalStart
,
diffChange
.
originalStart
+
diffChange
.
originalLength
-
1
);
const
modifiedCharSequence
=
modifiedLineSequence
.
getCharSequence
(
shouldIgnoreTrimWhitespace
,
diffChange
.
modifiedStart
,
diffChange
.
modifiedStart
+
diffChange
.
modifiedLength
-
1
);
let
rawChanges
=
computeDiff
(
originalCharSequence
,
modifiedCharSequence
,
continueProcessingPredicate
,
true
);
...
...
@@ -379,7 +380,7 @@ export class DiffComputer {
if
(
this
.
shouldIgnoreTrimWhitespace
)
{
let
lineChanges
:
LineChange
[]
=
[];
for
(
let
i
=
0
,
length
=
rawChanges
.
length
;
i
<
length
;
i
++
)
{
lineChanges
.
push
(
LineChange
.
createFromDiffResult
(
rawChanges
[
i
],
this
.
original
,
this
.
modified
,
this
.
_continueProcessingPredicate
.
bind
(
this
),
this
.
shouldPostProcessCharChanges
));
lineChanges
.
push
(
LineChange
.
createFromDiffResult
(
this
.
shouldIgnoreTrimWhitespace
,
rawChanges
[
i
],
this
.
original
,
this
.
modified
,
this
.
_continueProcessingPredicate
.
bind
(
this
),
this
.
shouldPostProcessCharChanges
));
}
return
lineChanges
;
}
...
...
@@ -454,7 +455,7 @@ export class DiffComputer {
if
(
nextChange
)
{
// Emit the actual change
result
.
push
(
LineChange
.
createFromDiffResult
(
nextChange
,
this
.
original
,
this
.
modified
,
this
.
_continueProcessingPredicate
.
bind
(
this
),
this
.
shouldPostProcessCharChanges
));
result
.
push
(
LineChange
.
createFromDiffResult
(
this
.
shouldIgnoreTrimWhitespace
,
nextChange
,
this
.
original
,
this
.
modified
,
this
.
_continueProcessingPredicate
.
bind
(
this
),
this
.
shouldPostProcessCharChanges
));
originalLineIndex
+=
nextChange
.
originalLength
;
modifiedLineIndex
+=
nextChange
.
modifiedLength
;
...
...
src/vs/editor/test/common/diff/diffComputer.test.ts
浏览文件 @
10ca8670
...
...
@@ -692,4 +692,24 @@ suite('Editor Diff - DiffComputer', () => {
];
assertDiff
(
original
,
modified
,
expected
,
true
,
false
);
});
test
(
'
issue #42751
'
,
()
=>
{
let
original
=
[
'
1
'
,
'
2
'
,
];
let
modified
=
[
'
1
'
,
'
3
'
,
];
let
expected
=
[
createLineChange
(
2
,
2
,
2
,
2
,
[
createCharChange
(
2
,
3
,
2
,
4
,
2
,
3
,
2
,
5
)
]
)
];
assertDiff
(
original
,
modified
,
expected
,
true
,
false
);
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录