Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e0c24908
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,发现更多精彩内容 >>
提交
e0c24908
编写于
3月 08, 2017
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fix #17246
上级
ef8fdc29
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
32 addition
and
5 deletion
+32
-5
src/vs/editor/browser/editor.all.ts
src/vs/editor/browser/editor.all.ts
+1
-1
src/vs/editor/contrib/format/browser/formatActions.ts
src/vs/editor/contrib/format/browser/formatActions.ts
+31
-4
未找到文件。
src/vs/editor/browser/editor.all.ts
浏览文件 @
e0c24908
...
@@ -18,7 +18,7 @@ import 'vs/editor/contrib/comment/common/comment';
...
@@ -18,7 +18,7 @@ import 'vs/editor/contrib/comment/common/comment';
import
'
vs/editor/contrib/contextmenu/browser/contextmenu
'
;
import
'
vs/editor/contrib/contextmenu/browser/contextmenu
'
;
import
'
vs/editor/contrib/diffNavigator/common/diffNavigator
'
;
import
'
vs/editor/contrib/diffNavigator/common/diffNavigator
'
;
import
'
vs/editor/contrib/find/browser/find
'
;
import
'
vs/editor/contrib/find/browser/find
'
;
import
'
vs/editor/contrib/format/
common
/formatActions
'
;
import
'
vs/editor/contrib/format/
browser
/formatActions
'
;
import
'
vs/editor/contrib/goToDeclaration/browser/goToDeclaration
'
;
import
'
vs/editor/contrib/goToDeclaration/browser/goToDeclaration
'
;
import
'
vs/editor/contrib/gotoError/browser/gotoError
'
;
import
'
vs/editor/contrib/gotoError/browser/gotoError
'
;
import
'
vs/editor/contrib/hover/browser/hover
'
;
import
'
vs/editor/contrib/hover/browser/hover
'
;
...
...
src/vs/editor/contrib/format/
common
/formatActions.ts
→
src/vs/editor/contrib/format/
browser
/formatActions.ts
浏览文件 @
e0c24908
...
@@ -14,16 +14,40 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
...
@@ -14,16 +14,40 @@ import { ContextKeyExpr } from 'vs/platform/contextkey/common/contextkey';
import
{
editorAction
,
ServicesAccessor
,
EditorAction
,
commonEditorContribution
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
editorAction
,
ServicesAccessor
,
EditorAction
,
commonEditorContribution
}
from
'
vs/editor/common/editorCommonExtensions
'
;
import
{
OnTypeFormattingEditProviderRegistry
,
DocumentRangeFormattingEditProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
OnTypeFormattingEditProviderRegistry
,
DocumentRangeFormattingEditProviderRegistry
}
from
'
vs/editor/common/modes
'
;
import
{
getOnTypeFormattingEdits
,
getDocumentFormattingEdits
,
getDocumentRangeFormattingEdits
}
from
'
../common/format
'
;
import
{
getOnTypeFormattingEdits
,
getDocumentFormattingEdits
,
getDocumentRangeFormattingEdits
}
from
'
../common/format
'
;
import
{
EditOperationsCommand
}
from
'
./formatCommand
'
;
import
{
EditOperationsCommand
}
from
'
.
./common
/formatCommand
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
CommandsRegistry
}
from
'
vs/platform/commands/common/commands
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/common/services/codeEditorService
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
CharacterSet
}
from
'
vs/editor/common/core/characterClassifier
'
;
import
{
CharacterSet
}
from
'
vs/editor/common/core/characterClassifier
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
alert
}
from
'
vs/base/browser/ui/aria/aria
'
;
import
ModeContextKeys
=
editorCommon
.
ModeContextKeys
;
import
ModeContextKeys
=
editorCommon
.
ModeContextKeys
;
import
EditorContextKeys
=
editorCommon
.
EditorContextKeys
;
import
EditorContextKeys
=
editorCommon
.
EditorContextKeys
;
function
alertFormattingEdits
(
edits
:
editorCommon
.
ISingleEditOperation
[]):
void
{
let
{
range
}
=
edits
[
0
];
for
(
let
i
=
1
;
i
<
edits
.
length
;
i
++
)
{
range
=
Range
.
plusRange
(
range
,
edits
[
i
].
range
);
}
const
{
startLineNumber
,
endLineNumber
}
=
range
;
if
(
startLineNumber
===
endLineNumber
)
{
if
(
edits
.
length
===
1
)
{
alert
(
nls
.
localize
(
'
hint11
'
,
"
Made 1 formatting edit on line {0}
"
,
startLineNumber
));
}
else
{
alert
(
nls
.
localize
(
'
hintn1
'
,
"
Made {0} formatting edits on line {1}
"
,
edits
.
length
,
startLineNumber
));
}
}
else
{
if
(
edits
.
length
===
1
)
{
alert
(
nls
.
localize
(
'
hint1n
'
,
"
Made 1 formatting edit between lines {0} and {1}
"
,
startLineNumber
,
endLineNumber
));
}
else
{
alert
(
nls
.
localize
(
'
hintnn
'
,
"
Made {0} formatting edits between lines {1} and {2}
"
,
edits
.
length
,
startLineNumber
,
endLineNumber
));
}
}
}
@
commonEditorContribution
@
commonEditorContribution
class
FormatOnType
implements
editorCommon
.
IEditorContribution
{
class
FormatOnType
implements
editorCommon
.
IEditorContribution
{
...
@@ -134,6 +158,7 @@ class FormatOnType implements editorCommon.IEditorContribution {
...
@@ -134,6 +158,7 @@ class FormatOnType implements editorCommon.IEditorContribution {
}
}
this
.
editor
.
executeCommand
(
this
.
getId
(),
new
EditOperationsCommand
(
edits
,
this
.
editor
.
getSelection
()));
this
.
editor
.
executeCommand
(
this
.
getId
(),
new
EditOperationsCommand
(
edits
,
this
.
editor
.
getSelection
()));
alertFormattingEdits
(
edits
);
},
(
err
)
=>
{
},
(
err
)
=>
{
unbind
.
dispose
();
unbind
.
dispose
();
...
@@ -218,6 +243,7 @@ class FormatOnPaste implements editorCommon.IEditorContribution {
...
@@ -218,6 +243,7 @@ class FormatOnPaste implements editorCommon.IEditorContribution {
}
}
const
command
=
new
EditOperationsCommand
(
edits
,
this
.
editor
.
getSelection
());
const
command
=
new
EditOperationsCommand
(
edits
,
this
.
editor
.
getSelection
());
this
.
editor
.
executeCommand
(
this
.
getId
(),
command
);
this
.
editor
.
executeCommand
(
this
.
getId
(),
command
);
alertFormattingEdits
(
edits
);
});
});
}
}
...
@@ -252,6 +278,7 @@ export abstract class AbstractFormatAction extends EditorAction {
...
@@ -252,6 +278,7 @@ export abstract class AbstractFormatAction extends EditorAction {
}
}
const
command
=
new
EditOperationsCommand
(
edits
,
editor
.
getSelection
());
const
command
=
new
EditOperationsCommand
(
edits
,
editor
.
getSelection
());
editor
.
executeCommand
(
this
.
id
,
command
);
editor
.
executeCommand
(
this
.
id
,
command
);
alertFormattingEdits
(
edits
);
editor
.
focus
();
editor
.
focus
();
});
});
}
}
...
@@ -284,7 +311,7 @@ export class FormatDocumentAction extends AbstractFormatAction {
...
@@ -284,7 +311,7 @@ export class FormatDocumentAction extends AbstractFormatAction {
protected
_getFormattingEdits
(
editor
:
editorCommon
.
ICommonCodeEditor
):
TPromise
<
editorCommon
.
ISingleEditOperation
[]
>
{
protected
_getFormattingEdits
(
editor
:
editorCommon
.
ICommonCodeEditor
):
TPromise
<
editorCommon
.
ISingleEditOperation
[]
>
{
const
model
=
editor
.
getModel
();
const
model
=
editor
.
getModel
();
const
{
tabSize
,
insertSpaces
}
=
model
.
getOptions
();
const
{
tabSize
,
insertSpaces
}
=
model
.
getOptions
();
return
getDocumentFormattingEdits
(
model
,
{
tabSize
,
insertSpaces
});
return
getDocumentFormattingEdits
(
model
,
{
tabSize
,
insertSpaces
});
}
}
}
}
...
@@ -311,7 +338,7 @@ export class FormatSelectionAction extends AbstractFormatAction {
...
@@ -311,7 +338,7 @@ export class FormatSelectionAction extends AbstractFormatAction {
protected
_getFormattingEdits
(
editor
:
editorCommon
.
ICommonCodeEditor
):
TPromise
<
editorCommon
.
ISingleEditOperation
[]
>
{
protected
_getFormattingEdits
(
editor
:
editorCommon
.
ICommonCodeEditor
):
TPromise
<
editorCommon
.
ISingleEditOperation
[]
>
{
const
model
=
editor
.
getModel
();
const
model
=
editor
.
getModel
();
const
{
tabSize
,
insertSpaces
}
=
model
.
getOptions
();
const
{
tabSize
,
insertSpaces
}
=
model
.
getOptions
();
return
getDocumentRangeFormattingEdits
(
model
,
editor
.
getSelection
(),
{
tabSize
,
insertSpaces
});
return
getDocumentRangeFormattingEdits
(
model
,
editor
.
getSelection
(),
{
tabSize
,
insertSpaces
});
}
}
}
}
...
@@ -328,7 +355,7 @@ CommandsRegistry.registerCommand('editor.action.format', accessor => {
...
@@ -328,7 +355,7 @@ CommandsRegistry.registerCommand('editor.action.format', accessor => {
_getFormattingEdits
(
editor
:
editorCommon
.
ICommonCodeEditor
):
TPromise
<
editorCommon
.
ISingleEditOperation
[]
>
{
_getFormattingEdits
(
editor
:
editorCommon
.
ICommonCodeEditor
):
TPromise
<
editorCommon
.
ISingleEditOperation
[]
>
{
const
model
=
editor
.
getModel
();
const
model
=
editor
.
getModel
();
const
editorSelection
=
editor
.
getSelection
();
const
editorSelection
=
editor
.
getSelection
();
const
{
tabSize
,
insertSpaces
}
=
model
.
getOptions
();
const
{
tabSize
,
insertSpaces
}
=
model
.
getOptions
();
return
editorSelection
.
isEmpty
()
return
editorSelection
.
isEmpty
()
?
getDocumentFormattingEdits
(
model
,
{
tabSize
,
insertSpaces
})
?
getDocumentFormattingEdits
(
model
,
{
tabSize
,
insertSpaces
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录