Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
94f93598
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,发现更多精彩内容 >>
提交
94f93598
编写于
2月 06, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
don't push undo stops for format on save, #90100
上级
09ed1c7c
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
14 addition
and
14 deletion
+14
-14
src/vs/editor/contrib/format/format.ts
src/vs/editor/contrib/format/format.ts
+2
-4
src/vs/editor/contrib/format/formattingEdit.ts
src/vs/editor/contrib/format/formattingEdit.ts
+7
-3
src/vs/workbench/api/browser/mainThreadSaveParticipant.ts
src/vs/workbench/api/browser/mainThreadSaveParticipant.ts
+5
-7
未找到文件。
src/vs/editor/contrib/format/format.ts
浏览文件 @
94f93598
...
@@ -178,9 +178,8 @@ export async function formatDocumentRangeWithProvider(
...
@@ -178,9 +178,8 @@ export async function formatDocumentRangeWithProvider(
if
(
isCodeEditor
(
editorOrModel
))
{
if
(
isCodeEditor
(
editorOrModel
))
{
// use editor to apply edits
// use editor to apply edits
FormattingEdit
.
execute
(
editorOrModel
,
edits
);
FormattingEdit
.
execute
(
editorOrModel
,
edits
,
true
);
alertFormattingEdits
(
edits
);
alertFormattingEdits
(
edits
);
editorOrModel
.
pushUndoStop
();
editorOrModel
.
revealPositionInCenterIfOutsideViewport
(
editorOrModel
.
getPosition
(),
ScrollType
.
Immediate
);
editorOrModel
.
revealPositionInCenterIfOutsideViewport
(
editorOrModel
.
getPosition
(),
ScrollType
.
Immediate
);
}
else
{
}
else
{
...
@@ -265,11 +264,10 @@ export async function formatDocumentWithProvider(
...
@@ -265,11 +264,10 @@ export async function formatDocumentWithProvider(
if
(
isCodeEditor
(
editorOrModel
))
{
if
(
isCodeEditor
(
editorOrModel
))
{
// use editor to apply edits
// use editor to apply edits
FormattingEdit
.
execute
(
editorOrModel
,
edits
);
FormattingEdit
.
execute
(
editorOrModel
,
edits
,
mode
!==
FormattingMode
.
Silent
);
if
(
mode
!==
FormattingMode
.
Silent
)
{
if
(
mode
!==
FormattingMode
.
Silent
)
{
alertFormattingEdits
(
edits
);
alertFormattingEdits
(
edits
);
editorOrModel
.
pushUndoStop
();
editorOrModel
.
revealPositionInCenterIfOutsideViewport
(
editorOrModel
.
getPosition
(),
ScrollType
.
Immediate
);
editorOrModel
.
revealPositionInCenterIfOutsideViewport
(
editorOrModel
.
getPosition
(),
ScrollType
.
Immediate
);
}
}
...
...
src/vs/editor/contrib/format/formattingEdit.ts
浏览文件 @
94f93598
...
@@ -43,8 +43,10 @@ export class FormattingEdit {
...
@@ -43,8 +43,10 @@ export class FormattingEdit {
return
fullModelRange
.
equalsRange
(
editRange
);
return
fullModelRange
.
equalsRange
(
editRange
);
}
}
static
execute
(
editor
:
ICodeEditor
,
_edits
:
TextEdit
[])
{
static
execute
(
editor
:
ICodeEditor
,
_edits
:
TextEdit
[],
addUndoStops
:
boolean
)
{
editor
.
pushUndoStop
();
if
(
addUndoStops
)
{
editor
.
pushUndoStop
();
}
const
edits
=
FormattingEdit
.
_handleEolEdits
(
editor
,
_edits
);
const
edits
=
FormattingEdit
.
_handleEolEdits
(
editor
,
_edits
);
if
(
edits
.
length
===
1
&&
FormattingEdit
.
_isFullModelReplaceEdit
(
editor
,
edits
[
0
]))
{
if
(
edits
.
length
===
1
&&
FormattingEdit
.
_isFullModelReplaceEdit
(
editor
,
edits
[
0
]))
{
// We use replace semantics and hope that markers stay put...
// We use replace semantics and hope that markers stay put...
...
@@ -52,6 +54,8 @@ export class FormattingEdit {
...
@@ -52,6 +54,8 @@ export class FormattingEdit {
}
else
{
}
else
{
editor
.
executeEdits
(
'
formatEditsCommand
'
,
edits
.
map
(
edit
=>
EditOperation
.
replaceMove
(
Range
.
lift
(
edit
.
range
),
edit
.
text
)));
editor
.
executeEdits
(
'
formatEditsCommand
'
,
edits
.
map
(
edit
=>
EditOperation
.
replaceMove
(
Range
.
lift
(
edit
.
range
),
edit
.
text
)));
}
}
editor
.
pushUndoStop
();
if
(
addUndoStops
)
{
editor
.
pushUndoStop
();
}
}
}
}
}
src/vs/workbench/api/browser/mainThreadSaveParticipant.ts
浏览文件 @
94f93598
...
@@ -33,10 +33,6 @@ import { ExtHostContext, ExtHostDocumentSaveParticipantShape, IExtHostContext }
...
@@ -33,10 +33,6 @@ import { ExtHostContext, ExtHostDocumentSaveParticipantShape, IExtHostContext }
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
ILabelService
}
from
'
vs/platform/label/common/label
'
;
import
{
canceled
}
from
'
vs/base/common/errors
'
;
import
{
canceled
}
from
'
vs/base/common/errors
'
;
export
interface
ICodeActionsOnSaveOptions
{
[
kind
:
string
]:
boolean
;
}
export
interface
ISaveParticipantParticipant
{
export
interface
ISaveParticipantParticipant
{
participate
(
model
:
IResolvedTextFileEditorModel
,
env
:
{
reason
:
SaveReason
},
progress
:
IProgress
<
IProgressStep
>
,
token
:
CancellationToken
):
Promise
<
void
>
;
participate
(
model
:
IResolvedTextFileEditorModel
,
env
:
{
reason
:
SaveReason
},
progress
:
IProgress
<
IProgressStep
>
,
token
:
CancellationToken
):
Promise
<
void
>
;
}
}
...
@@ -242,11 +238,10 @@ class CodeActionOnSaveParticipant implements ISaveParticipantParticipant {
...
@@ -242,11 +238,10 @@ class CodeActionOnSaveParticipant implements ISaveParticipantParticipant {
if
(
env
.
reason
===
SaveReason
.
AUTO
)
{
if
(
env
.
reason
===
SaveReason
.
AUTO
)
{
return
undefined
;
return
undefined
;
}
}
const
model
=
editorModel
.
textEditorModel
;
const
model
=
editorModel
.
textEditorModel
;
const
settingsOverrides
=
{
overrideIdentifier
:
model
.
getLanguageIdentifier
().
language
,
resource
:
editorModel
.
resource
};
const
settingsOverrides
=
{
overrideIdentifier
:
model
.
getLanguageIdentifier
().
language
,
resource
:
editorModel
.
resource
};
const
setting
=
this
.
_configurationService
.
getValue
<
ICodeActionsOnSaveOptions
>
(
'
editor.codeActionsOnSave
'
,
settingsOverrides
);
const
setting
=
this
.
_configurationService
.
getValue
<
{
[
kind
:
string
]:
boolean
}
>
(
'
editor.codeActionsOnSave
'
,
settingsOverrides
);
if
(
!
setting
)
{
if
(
!
setting
)
{
return
undefined
;
return
undefined
;
}
}
...
@@ -380,9 +375,10 @@ export class SaveParticipant implements ISaveParticipant {
...
@@ -380,9 +375,10 @@ export class SaveParticipant implements ISaveParticipant {
cancellable
:
true
,
cancellable
:
true
,
delay
:
model
.
isDirty
()
?
3000
:
5000
delay
:
model
.
isDirty
()
?
3000
:
5000
},
async
progress
=>
{
},
async
progress
=>
{
// undoStop before participation
model
.
textEditorModel
.
pushStackElement
();
for
(
let
p
of
this
.
_saveParticipants
.
getValue
())
{
for
(
let
p
of
this
.
_saveParticipants
.
getValue
())
{
if
(
cts
.
token
.
isCancellationRequested
)
{
if
(
cts
.
token
.
isCancellationRequested
)
{
break
;
break
;
}
}
...
@@ -394,6 +390,8 @@ export class SaveParticipant implements ISaveParticipant {
...
@@ -394,6 +390,8 @@ export class SaveParticipant implements ISaveParticipant {
}
}
}
}
// undoStop after participation
model
.
textEditorModel
.
pushStackElement
();
},
()
=>
{
},
()
=>
{
// user cancel
// user cancel
cts
.
dispose
(
true
);
cts
.
dispose
(
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录