Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
042caca1
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,发现更多精彩内容 >>
未验证
提交
042caca1
编写于
10月 16, 2019
作者:
A
Alex Dima
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Add `diffEditor.maximumComputationTime`
上级
37d462bf
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
42 addition
and
13 deletion
+42
-13
src/vs/editor/browser/widget/diffEditorWidget.ts
src/vs/editor/browser/widget/diffEditorWidget.ts
+12
-1
src/vs/editor/common/config/commonEditorConfig.ts
src/vs/editor/common/config/commonEditorConfig.ts
+5
-0
src/vs/editor/common/config/editorOptions.ts
src/vs/editor/common/config/editorOptions.ts
+5
-0
src/vs/editor/common/diff/diffComputer.ts
src/vs/editor/common/diff/diffComputer.ts
+3
-3
src/vs/editor/common/services/editorSimpleWorker.ts
src/vs/editor/common/services/editorSimpleWorker.ts
+5
-3
src/vs/editor/common/services/editorWorkerService.ts
src/vs/editor/common/services/editorWorkerService.ts
+1
-1
src/vs/editor/common/services/editorWorkerServiceImpl.ts
src/vs/editor/common/services/editorWorkerServiceImpl.ts
+4
-4
src/vs/editor/test/common/diff/diffComputer.test.ts
src/vs/editor/test/common/diff/diffComputer.test.ts
+2
-1
src/vs/monaco.d.ts
src/vs/monaco.d.ts
+5
-0
未找到文件。
src/vs/editor/browser/widget/diffEditorWidget.ts
浏览文件 @
042caca1
...
...
@@ -203,6 +203,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
private
_originalIsEditable
:
boolean
;
private
_renderSideBySide
:
boolean
;
private
_maximumComputationTime
:
number
;
private
_renderIndicators
:
boolean
;
private
_enableSplitViewResizing
:
boolean
;
private
_strategy
!
:
IDiffEditorWidgetStyle
;
...
...
@@ -252,6 +253,12 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
this
.
_renderSideBySide
=
options
.
renderSideBySide
;
}
// maximumComputationTime
this
.
_maximumComputationTime
=
5000
;
if
(
typeof
options
.
maximumComputationTime
!==
'
undefined
'
)
{
this
.
_maximumComputationTime
=
options
.
maximumComputationTime
;
}
// ignoreTrimWhitespace
this
.
_ignoreTrimWhitespace
=
true
;
if
(
typeof
options
.
ignoreTrimWhitespace
!==
'
undefined
'
)
{
...
...
@@ -623,6 +630,10 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
}
}
if
(
typeof
newOptions
.
maximumComputationTime
!==
'
undefined
'
)
{
this
.
_maximumComputationTime
=
newOptions
.
maximumComputationTime
;
}
let
beginUpdateDecorations
=
false
;
if
(
typeof
newOptions
.
ignoreTrimWhitespace
!==
'
undefined
'
)
{
...
...
@@ -968,7 +979,7 @@ export class DiffEditorWidget extends Disposable implements editorBrowser.IDiffE
return
;
}
this
.
_editorWorkerService
.
computeDiff
(
currentOriginalModel
.
uri
,
currentModifiedModel
.
uri
,
this
.
_ignoreTrimWhitespace
).
then
((
result
)
=>
{
this
.
_editorWorkerService
.
computeDiff
(
currentOriginalModel
.
uri
,
currentModifiedModel
.
uri
,
this
.
_ignoreTrimWhitespace
,
this
.
_maximumComputationTime
).
then
((
result
)
=>
{
if
(
currentToken
===
this
.
_diffComputationToken
&&
currentOriginalModel
===
this
.
originalEditor
.
getModel
()
&&
currentModifiedModel
===
this
.
modifiedEditor
.
getModel
()
...
...
src/vs/editor/common/config/commonEditorConfig.ts
浏览文件 @
042caca1
...
...
@@ -462,6 +462,11 @@ const editorConfiguration: IConfigurationNode = {
default
:
750
,
description
:
nls
.
localize
(
'
codeActionsOnSaveTimeout
'
,
"
Timeout in milliseconds after which the code actions that are run on save are cancelled.
"
)
},
'
diffEditor.maximumComputationTime
'
:
{
type
:
'
number
'
,
default
:
5000
,
description
:
nls
.
localize
(
'
maximumComputationTime
'
,
"
Timeout in milliseconds after which diff computation is cancelled.
"
)
},
'
diffEditor.renderSideBySide
'
:
{
type
:
'
boolean
'
,
default
:
true
,
...
...
src/vs/editor/common/config/editorOptions.ts
浏览文件 @
042caca1
...
...
@@ -538,6 +538,11 @@ export interface IDiffEditorOptions extends IEditorOptions {
* Defaults to true.
*/
renderSideBySide
?:
boolean
;
/**
* Timeout in milliseconds after which diff computation is cancelled.
* Defaults to 5000.
*/
maximumComputationTime
?:
number
;
/**
* Compute the diff by ignoring leading/trailing whitespace
* Defaults to true.
...
...
src/vs/editor/common/diff/diffComputer.ts
浏览文件 @
042caca1
...
...
@@ -7,7 +7,6 @@ import { IDiffChange, ISequence, LcsDiff, IDiffResult } from 'vs/base/common/dif
import
*
as
strings
from
'
vs/base/common/strings
'
;
import
{
ICharChange
,
ILineChange
}
from
'
vs/editor/common/editorCommon
'
;
const
MAXIMUM_RUN_TIME
=
5000
;
// 5 seconds
const
MINIMUM_MATCHING_CHARACTER_LENGTH
=
3
;
export
interface
IDiffComputerResult
{
...
...
@@ -280,6 +279,7 @@ export interface IDiffComputerOpts {
shouldPostProcessCharChanges
:
boolean
;
shouldIgnoreTrimWhitespace
:
boolean
;
shouldMakePrettyDiff
:
boolean
;
maximumComputationTime
:
number
;
}
export
class
DiffComputer
{
...
...
@@ -305,8 +305,8 @@ export class DiffComputer {
this
.
original
=
new
LineSequence
(
originalLines
);
this
.
modified
=
new
LineSequence
(
modifiedLines
);
this
.
continueLineDiff
=
createContinueProcessingPredicate
(
MAXIMUM_RUN_TIME
);
this
.
continueCharDiff
=
createContinueProcessingPredicate
(
MAXIMUM_RUN_TIME
);
this
.
continueLineDiff
=
createContinueProcessingPredicate
(
opts
.
maximumComputationTime
);
this
.
continueCharDiff
=
createContinueProcessingPredicate
(
opts
.
maximumComputationTime
===
0
?
0
:
Math
.
min
(
opts
.
maximumComputationTime
,
5000
));
// never run after 5s for character changes...
}
public
computeDiff
():
IDiffComputerResult
{
...
...
src/vs/editor/common/services/editorSimpleWorker.ts
浏览文件 @
042caca1
...
...
@@ -377,7 +377,7 @@ export class EditorSimpleWorker implements IRequestHandler, IDisposable {
// ---- BEGIN diff --------------------------------------------------------------------------
public
async
computeDiff
(
originalUrl
:
string
,
modifiedUrl
:
string
,
ignoreTrimWhitespace
:
boolean
):
Promise
<
IDiffComputationResult
|
null
>
{
public
async
computeDiff
(
originalUrl
:
string
,
modifiedUrl
:
string
,
ignoreTrimWhitespace
:
boolean
,
maximumComputationTime
:
number
):
Promise
<
IDiffComputationResult
|
null
>
{
const
original
=
this
.
_getModel
(
originalUrl
);
const
modified
=
this
.
_getModel
(
modifiedUrl
);
if
(
!
original
||
!
modified
)
{
...
...
@@ -390,7 +390,8 @@ export class EditorSimpleWorker implements IRequestHandler, IDisposable {
shouldComputeCharChanges
:
true
,
shouldPostProcessCharChanges
:
true
,
shouldIgnoreTrimWhitespace
:
ignoreTrimWhitespace
,
shouldMakePrettyDiff
:
true
shouldMakePrettyDiff
:
true
,
maximumComputationTime
:
maximumComputationTime
});
const
diffResult
=
diffComputer
.
computeDiff
();
...
...
@@ -431,7 +432,8 @@ export class EditorSimpleWorker implements IRequestHandler, IDisposable {
shouldComputeCharChanges
:
false
,
shouldPostProcessCharChanges
:
false
,
shouldIgnoreTrimWhitespace
:
ignoreTrimWhitespace
,
shouldMakePrettyDiff
:
true
shouldMakePrettyDiff
:
true
,
maximumComputationTime
:
1000
});
return
diffComputer
.
computeDiff
().
changes
;
}
...
...
src/vs/editor/common/services/editorWorkerService.ts
浏览文件 @
042caca1
...
...
@@ -22,7 +22,7 @@ export interface IEditorWorkerService {
_serviceBrand
:
undefined
;
canComputeDiff
(
original
:
URI
,
modified
:
URI
):
boolean
;
computeDiff
(
original
:
URI
,
modified
:
URI
,
ignoreTrimWhitespace
:
boolean
):
Promise
<
IDiffComputationResult
|
null
>
;
computeDiff
(
original
:
URI
,
modified
:
URI
,
ignoreTrimWhitespace
:
boolean
,
maximumComputationTime
:
number
):
Promise
<
IDiffComputationResult
|
null
>
;
canComputeDirtyDiff
(
original
:
URI
,
modified
:
URI
):
boolean
;
computeDirtyDiff
(
original
:
URI
,
modified
:
URI
,
ignoreTrimWhitespace
:
boolean
):
Promise
<
IChange
[]
|
null
>
;
...
...
src/vs/editor/common/services/editorWorkerServiceImpl.ts
浏览文件 @
042caca1
...
...
@@ -82,8 +82,8 @@ export class EditorWorkerServiceImpl extends Disposable implements IEditorWorker
return
(
canSyncModel
(
this
.
_modelService
,
original
)
&&
canSyncModel
(
this
.
_modelService
,
modified
));
}
public
computeDiff
(
original
:
URI
,
modified
:
URI
,
ignoreTrimWhitespace
:
boolean
):
Promise
<
IDiffComputationResult
|
null
>
{
return
this
.
_workerManager
.
withWorker
().
then
(
client
=>
client
.
computeDiff
(
original
,
modified
,
ignoreTrimWhitespace
));
public
computeDiff
(
original
:
URI
,
modified
:
URI
,
ignoreTrimWhitespace
:
boolean
,
maximumComputationTime
:
number
):
Promise
<
IDiffComputationResult
|
null
>
{
return
this
.
_workerManager
.
withWorker
().
then
(
client
=>
client
.
computeDiff
(
original
,
modified
,
ignoreTrimWhitespace
,
maximumComputationTime
));
}
public
canComputeDirtyDiff
(
original
:
URI
,
modified
:
URI
):
boolean
{
...
...
@@ -409,9 +409,9 @@ export class EditorWorkerClient extends Disposable {
});
}
public
computeDiff
(
original
:
URI
,
modified
:
URI
,
ignoreTrimWhitespace
:
boolean
):
Promise
<
IDiffComputationResult
|
null
>
{
public
computeDiff
(
original
:
URI
,
modified
:
URI
,
ignoreTrimWhitespace
:
boolean
,
maximumComputationTime
:
number
):
Promise
<
IDiffComputationResult
|
null
>
{
return
this
.
_withSyncedResources
([
original
,
modified
]).
then
(
proxy
=>
{
return
proxy
.
computeDiff
(
original
.
toString
(),
modified
.
toString
(),
ignoreTrimWhitespace
);
return
proxy
.
computeDiff
(
original
.
toString
(),
modified
.
toString
(),
ignoreTrimWhitespace
,
maximumComputationTime
);
});
}
...
...
src/vs/editor/test/common/diff/diffComputer.test.ts
浏览文件 @
042caca1
...
...
@@ -55,7 +55,8 @@ function assertDiff(originalLines: string[], modifiedLines: string[], expectedCh
shouldComputeCharChanges
,
shouldPostProcessCharChanges
,
shouldIgnoreTrimWhitespace
,
shouldMakePrettyDiff
:
true
shouldMakePrettyDiff
:
true
,
maximumComputationTime
:
0
});
let
changes
=
diffComputer
.
computeDiff
().
changes
;
...
...
src/vs/monaco.d.ts
浏览文件 @
042caca1
...
...
@@ -2941,6 +2941,11 @@ declare namespace monaco.editor {
* Defaults to true.
*/
renderSideBySide
?:
boolean
;
/**
* Timeout in milliseconds after which diff computation is cancelled.
* Defaults to 5000.
*/
maximumComputationTime
?:
number
;
/**
* Compute the diff by ignoring leading/trailing whitespace
* Defaults to true.
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录