Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
70914641
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,发现更多精彩内容 >>
提交
70914641
编写于
4月 27, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add format notebook command, #96239
上级
58987c21
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
94 addition
and
2 deletion
+94
-2
src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.ts
...nch/contrib/notebook/browser/contrib/format/formatting.ts
+88
-0
src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
...rkbench/contrib/notebook/browser/notebook.contribution.ts
+2
-1
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+4
-1
未找到文件。
src/vs/workbench/contrib/notebook/browser/contrib/format/formatting.ts
0 → 100644
浏览文件 @
70914641
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
registerAction2
,
Action2
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
localize
}
from
'
vs/nls
'
;
import
{
NOTEBOOK_IS_ACTIVE_EDITOR
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
KeyCode
,
KeyMod
}
from
'
vs/base/common/keyCodes
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
getActiveNotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/contrib/coreActions
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
ITextModelService
}
from
'
vs/editor/common/services/resolverService
'
;
import
{
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
{
getDocumentFormattingEditsUntilResult
}
from
'
vs/editor/contrib/format/format
'
;
import
{
IEditorWorkerService
}
from
'
vs/editor/common/services/editorWorkerService
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
IBulkEditService
}
from
'
vs/editor/browser/services/bulkEditService
'
;
import
{
WorkspaceTextEdit
}
from
'
vs/editor/common/modes
'
;
import
{
EditorContextKeys
}
from
'
vs/editor/common/editorContextKeys
'
;
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
'
notebook.format
'
,
title
:
localize
(
'
format.title
'
,
'
Format Notebook
'
),
category
:
localize
(
'
cat
'
,
"
Notebook
"
),
keybinding
:
{
when
:
ContextKeyExpr
.
and
(
NOTEBOOK_IS_ACTIVE_EDITOR
,
EditorContextKeys
.
editorTextFocus
.
toNegated
()),
primary
:
KeyMod
.
Shift
|
KeyMod
.
Alt
|
KeyCode
.
KEY_F
,
linux
:
{
primary
:
KeyMod
.
CtrlCmd
|
KeyMod
.
Shift
|
KeyCode
.
KEY_I
},
weight
:
KeybindingWeight
.
WorkbenchContrib
},
f1
:
true
});
}
async
run
(
accessor
:
ServicesAccessor
):
Promise
<
void
>
{
const
editorService
=
accessor
.
get
(
IEditorService
);
const
textModelService
=
accessor
.
get
(
ITextModelService
);
const
editorWorkerService
=
accessor
.
get
(
IEditorWorkerService
);
const
bulkEditService
=
accessor
.
get
(
IBulkEditService
);
const
editor
=
getActiveNotebookEditor
(
editorService
);
if
(
!
editor
||
!
editor
.
viewModel
)
{
return
;
}
const
notebook
=
editor
.
viewModel
.
notebookDocument
;
const
dispoables
=
new
DisposableStore
();
try
{
const
edits
:
WorkspaceTextEdit
[]
=
[];
for
(
let
cell
of
notebook
.
cells
)
{
const
ref
=
await
textModelService
.
createModelReference
(
cell
.
uri
);
dispoables
.
add
(
ref
);
const
model
=
ref
.
object
.
textEditorModel
;
const
formatEdits
=
await
getDocumentFormattingEditsUntilResult
(
editorWorkerService
,
model
,
model
.
getOptions
(),
CancellationToken
.
None
);
if
(
formatEdits
)
{
formatEdits
.
forEach
(
edit
=>
edits
.
push
({
edit
,
resource
:
model
.
uri
,
modelVersionId
:
model
.
getVersionId
()
}));
}
}
await
bulkEditService
.
apply
(
{
edits
},
{
label
:
localize
(
'
label
'
,
"
Format Notebook
"
)
}
);
}
finally
{
dispoables
.
dispose
();
}
}
});
src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
浏览文件 @
70914641
...
...
@@ -39,8 +39,9 @@ import { CustomEditorInfo } from 'vs/workbench/contrib/customEditor/common/custo
// Editor Contribution
import
'
vs/workbench/contrib/notebook/browser/contrib/coreActions
'
;
import
'
vs/workbench/contrib/notebook/browser/contrib/fold/folding
'
;
import
'
vs/workbench/contrib/notebook/browser/contrib/find/findController
'
;
import
'
vs/workbench/contrib/notebook/browser/contrib/fold/folding
'
;
import
'
vs/workbench/contrib/notebook/browser/contrib/format/formatting
'
;
// Output renderers registration
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
70914641
...
...
@@ -17,7 +17,7 @@ import { CodeEditorWidget } from 'vs/editor/browser/widget/codeEditorWidget';
import
{
BareFontInfo
}
from
'
vs/editor/common/config/fontInfo
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
FindMatch
}
from
'
vs/editor/common/model
'
;
import
{
RawContextKey
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
RawContextKey
,
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
OutputRenderer
}
from
'
vs/workbench/contrib/notebook/browser/view/output/outputRenderer
'
;
import
{
CellViewModel
,
IModelDecorationsChangeAccessor
,
NotebookViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
...
...
@@ -26,6 +26,9 @@ import { Webview } from 'vs/workbench/contrib/webview/browser/webview';
export
const
KEYBINDING_CONTEXT_NOTEBOOK_FIND_WIDGET_FOCUSED
=
new
RawContextKey
<
boolean
>
(
'
notebookFindWidgetFocused
'
,
false
);
// Is Notebook
export
const
NOTEBOOK_IS_ACTIVE_EDITOR
=
ContextKeyExpr
.
equals
(
'
activeEditor
'
,
'
workbench.editor.notebook
'
);
// Editor keys
export
const
NOTEBOOK_EDITOR_FOCUSED
=
new
RawContextKey
<
boolean
>
(
'
notebookEditorFocused
'
,
false
);
export
const
NOTEBOOK_EDITOR_EDITABLE
=
new
RawContextKey
<
boolean
>
(
'
notebookEditable
'
,
true
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录