Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
674b5496
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,体验更适合开发者的 AI 搜索 >>
提交
674b5496
编写于
5月 21, 2020
作者:
R
Rob Lourens
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Eliminate duplicate runstate, simplify context keys in cellRenderer
上级
99ff35b0
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
26 addition
and
45 deletion
+26
-45
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
...workbench/contrib/notebook/browser/contrib/coreActions.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+0
-7
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+22
-28
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
...h/contrib/notebook/browser/viewModel/baseCellViewModel.ts
+1
-7
未找到文件。
src/vs/workbench/contrib/notebook/browser/contrib/coreActions.ts
浏览文件 @
674b5496
...
...
@@ -18,8 +18,8 @@ import { InputFocusedContext, InputFocusedContextKey } from 'vs/platform/context
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
KeybindingWeight
}
from
'
vs/platform/keybinding/common/keybindingsRegistry
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
QuickPickInput
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
CellRunState
,
ICellViewModel
,
INotebookEditor
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_RUNNABLE
,
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_EDITOR_EDITABLE
,
NOTEBOOK_EDITOR_EXECUTING_NOTEBOOK
,
NOTEBOOK_EDITOR_FOCUSED
,
NOTEBOOK_EDITOR_RUNNABLE
,
NOTEBOOK_IS_ACTIVE_EDITOR
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellKind
,
NOTEBOOK_EDITOR_CURSOR_BOUNDARY
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
ICellViewModel
,
INotebookEditor
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_RUNNABLE
,
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_EDITOR_EDITABLE
,
NOTEBOOK_EDITOR_EXECUTING_NOTEBOOK
,
NOTEBOOK_EDITOR_FOCUSED
,
NOTEBOOK_EDITOR_RUNNABLE
,
NOTEBOOK_IS_ACTIVE_EDITOR
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellKind
,
NOTEBOOK_EDITOR_CURSOR_BOUNDARY
,
NotebookCellRunState
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
...
...
@@ -429,7 +429,7 @@ export function getActiveNotebookEditor(editorService: IEditorService): INoteboo
}
async
function
runCell
(
context
:
INotebookCellActionContext
):
Promise
<
void
>
{
if
(
context
.
cell
.
runState
===
CellRunState
.
Running
)
{
if
(
context
.
cell
.
metadata
?.
runState
===
Notebook
CellRunState
.
Running
)
{
return
;
}
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
674b5496
...
...
@@ -107,7 +107,6 @@ export interface ICellViewModel {
language
:
string
;
cellKind
:
CellKind
;
editState
:
CellEditState
;
readonly
runState
:
CellRunState
;
currentTokenSource
:
CancellationTokenSource
|
undefined
;
focusMode
:
CellFocusMode
;
getText
():
string
;
...
...
@@ -475,11 +474,6 @@ export enum CellRevealPosition {
Center
}
export
enum
CellRunState
{
Idle
,
Running
}
export
enum
CellEditState
{
/**
* Default state.
...
...
@@ -511,7 +505,6 @@ export interface CellViewModelStateChangeEvent {
metadataChanged
?:
boolean
;
selectionChanged
?:
boolean
;
focusModeChanged
?:
boolean
;
runStateChanged
?:
boolean
;
editStateChanged
?:
boolean
;
languageChanged
?:
boolean
;
foldingStateChanged
?:
boolean
;
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
674b5496
...
...
@@ -35,7 +35,7 @@ import { IModeService } from 'vs/editor/common/services/modeService';
import
{
ContextAwareMenuEntryActionViewItem
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
import
{
IMenu
,
MenuItemAction
}
from
'
vs/platform/actions/common/actions
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
IContextKey
,
IContextKey
Service
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
IContextMenuService
}
from
'
vs/platform/contextview/browser/contextView
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
...
...
@@ -43,7 +43,7 @@ import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
BOTTOM_CELL_TOOLBAR_HEIGHT
,
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_MARGIN
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CancelCellAction
,
ChangeCellLanguageAction
,
ExecuteCellAction
,
INotebookCellActionContext
,
InsertCodeCellAction
,
InsertMarkdownCellAction
}
from
'
vs/workbench/contrib/notebook/browser/contrib/coreActions
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
C
ellRunState
,
C
odeCellRenderTemplate
,
ICellViewModel
,
INotebookCellList
,
INotebookEditor
,
MarkdownCellRenderTemplate
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_HAS_OUTPUTS
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_RUNNABLE
,
NOTEBOOK_CELL_RUN_STATE
,
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_VIEW_TYPE
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
CodeCellRenderTemplate
,
ICellViewModel
,
INotebookCellList
,
INotebookEditor
,
MarkdownCellRenderTemplate
,
NOTEBOOK_CELL_EDITABLE
,
NOTEBOOK_CELL_HAS_OUTPUTS
,
NOTEBOOK_CELL_MARKDOWN_EDIT_MODE
,
NOTEBOOK_CELL_RUNNABLE
,
NOTEBOOK_CELL_RUN_STATE
,
NOTEBOOK_CELL_TYPE
,
NOTEBOOK_VIEW_TYPE
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellMenus
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellMenus
'
;
import
{
CodeCell
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/codeCell
'
;
import
{
StatefullMarkdownCell
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/markdownCell
'
;
...
...
@@ -978,9 +978,14 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
return
templateData
;
}
private
updateForRunState
(
element
:
CodeCellViewModel
,
templateData
:
CodeCellRenderTemplate
,
runStateKey
:
IContextKey
<
string
>
):
void
{
runStateKey
.
set
(
CellRunState
[
element
.
runState
]);
if
(
element
.
runState
===
CellRunState
.
Running
)
{
private
updateForRunState
(
runState
:
NotebookCellRunState
|
undefined
,
templateData
:
CodeCellRenderTemplate
):
void
{
if
(
typeof
runState
===
'
undefined
'
)
{
runState
=
NotebookCellRunState
.
Idle
;
}
const
runStateKey
=
NOTEBOOK_CELL_RUN_STATE
.
bindTo
(
templateData
.
contextKeyService
);
runStateKey
.
set
(
NotebookCellRunState
[
runState
]);
if
(
runState
===
NotebookCellRunState
.
Running
)
{
templateData
.
progressBar
.
infinite
().
show
(
500
);
templateData
.
runToolbar
.
setActions
([
...
...
@@ -995,7 +1000,10 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
}
}
private
updateForMetadata
(
element
:
CodeCellViewModel
,
templateData
:
CodeCellRenderTemplate
,
cellEditableKey
:
IContextKey
<
boolean
>
,
cellRunnableKey
:
IContextKey
<
boolean
>
):
void
{
private
updateForMetadata
(
element
:
CodeCellViewModel
,
templateData
:
CodeCellRenderTemplate
):
void
{
const
cellEditableKey
=
NOTEBOOK_CELL_EDITABLE
.
bindTo
(
templateData
.
contextKeyService
);
const
cellRunnableKey
=
NOTEBOOK_CELL_RUNNABLE
.
bindTo
(
templateData
.
contextKeyService
);
const
metadata
=
element
.
getEvaluatedMetadata
(
this
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
metadata
);
DOM
.
toggleClass
(
templateData
.
cellContainer
,
'
runnable
'
,
!!
metadata
.
runnable
);
this
.
renderExecutionOrder
(
element
,
templateData
);
...
...
@@ -1028,6 +1036,8 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
if
(
typeof
metadata
.
breakpointMargin
===
'
boolean
'
)
{
this
.
editorOptions
.
setGlyphMargin
(
metadata
.
breakpointMargin
);
}
this
.
updateForRunState
(
metadata
.
runState
,
templateData
);
}
private
renderExecutionOrder
(
element
:
CodeCellViewModel
,
templateData
:
CodeCellRenderTemplate
):
void
{
...
...
@@ -1066,34 +1076,18 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
templateData
.
focusIndicator
.
style
.
height
=
`
${
element
.
layoutInfo
.
indicatorHeight
}
px`
;
}));
const
contextKeyService
=
this
.
contextKeyServiceProvider
(
templateData
.
container
);
const
runStateKey
=
NOTEBOOK_CELL_RUN_STATE
.
bindTo
(
contextKeyService
);
runStateKey
.
set
(
CellRunState
[
element
.
runState
]);
this
.
updateForRunState
(
element
,
templateData
,
runStateKey
);
elementDisposables
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
if
(
e
.
runStateChanged
)
{
this
.
updateForRunState
(
element
,
templateData
,
runStateKey
);
}
}));
const
cellHasOutputsContext
=
NOTEBOOK_CELL_HAS_OUTPUTS
.
bindTo
(
contextKeyService
);
const
cellHasOutputsContext
=
NOTEBOOK_CELL_HAS_OUTPUTS
.
bindTo
(
templateData
.
contextKeyService
);
cellHasOutputsContext
.
set
(
element
.
outputs
.
length
>
0
);
elementDisposables
.
add
(
element
.
onDidChangeOutputs
(()
=>
{
cellHasOutputsContext
.
set
(
element
.
outputs
.
length
>
0
);
}));
NOTEBOOK_CELL_TYPE
.
bindTo
(
contextKeyService
).
set
(
'
code
'
);
NOTEBOOK_VIEW_TYPE
.
bindTo
(
contextKeyService
).
set
(
element
.
viewType
);
const
metadata
=
element
.
getEvaluatedMetadata
(
this
.
notebookEditor
.
viewModel
!
.
notebookDocument
.
metadata
);
const
cellEditableKey
=
NOTEBOOK_CELL_EDITABLE
.
bindTo
(
contextKeyService
);
cellEditableKey
.
set
(
!!
metadata
.
editable
);
const
cellRunnableKey
=
NOTEBOOK_CELL_RUNNABLE
.
bindTo
(
contextKeyService
);
cellRunnableKey
.
set
(
!!
metadata
.
runnable
);
this
.
updateForMetadata
(
element
,
templateData
,
cellEditableKey
,
cellRunnableKey
);
NOTEBOOK_CELL_TYPE
.
bindTo
(
templateData
.
contextKeyService
).
set
(
'
code
'
);
NOTEBOOK_VIEW_TYPE
.
bindTo
(
templateData
.
contextKeyService
).
set
(
element
.
viewType
);
this
.
updateForMetadata
(
element
,
templateData
);
elementDisposables
.
add
(
element
.
onDidChangeState
((
e
)
=>
{
if
(
e
.
metadataChanged
)
{
this
.
updateForMetadata
(
element
,
templateData
,
cellEditableKey
,
cellRunnableKey
);
this
.
updateForMetadata
(
element
,
templateData
);
}
if
(
e
.
outputIsHoveredChanged
)
{
...
...
@@ -1101,7 +1095,7 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
}
}));
this
.
setupCellToolbarActions
(
contextKeyService
,
templateData
,
elementDisposables
);
this
.
setupCellToolbarActions
(
templateData
.
contextKeyService
,
templateData
,
elementDisposables
);
const
toolbarContext
=
<
INotebookCellActionContext
>
{
cell
:
element
,
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
浏览文件 @
674b5496
...
...
@@ -13,7 +13,7 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
SearchParams
}
from
'
vs/editor/common/model/textModelSearch
'
;
import
{
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_MARGIN
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFocusMode
,
C
ellRunState
,
C
ursorAtBoundary
,
CellViewModelStateChangeEvent
,
IEditableCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellEditState
,
CellFocusMode
,
CursorAtBoundary
,
CellViewModelStateChangeEvent
,
IEditableCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellKind
,
NotebookCellMetadata
,
NotebookDocumentMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
...
...
@@ -65,21 +65,15 @@ export abstract class BaseCellViewModel extends Disposable {
}
}
// TODO@roblourens - move any "run"/"status" concept to Code-specific places
private
_currentTokenSource
:
CancellationTokenSource
|
undefined
;
public
set
currentTokenSource
(
v
:
CancellationTokenSource
|
undefined
)
{
this
.
_currentTokenSource
=
v
;
this
.
_onDidChangeState
.
fire
({
runStateChanged
:
true
});
}
public
get
currentTokenSource
():
CancellationTokenSource
|
undefined
{
return
this
.
_currentTokenSource
;
}
get
runState
():
CellRunState
{
return
this
.
_currentTokenSource
?
CellRunState
.
Running
:
CellRunState
.
Idle
;
}
private
_focusMode
:
CellFocusMode
=
CellFocusMode
.
Container
;
get
focusMode
()
{
return
this
.
_focusMode
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录