Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
24c65476
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,发现更多精彩内容 >>
提交
24c65476
编写于
3月 13, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
cell state instead of isEditing boolean
上级
f48e190b
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
19 addition
and
45 deletion
+19
-45
src/vs/workbench/contrib/notebook/browser/contrib/notebookActions.ts
...bench/contrib/notebook/browser/contrib/notebookActions.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/contrib/notebookFindWidget.ts
...ch/contrib/notebook/browser/contrib/notebookFindWidget.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+1
-8
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+2
-2
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
...h/contrib/notebook/browser/view/renderers/markdownCell.ts
+4
-4
src/vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel.ts
...ntrib/notebook/browser/viewModel/notebookCellViewModel.ts
+7
-26
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
...h/contrib/notebook/browser/viewModel/notebookViewModel.ts
+3
-3
未找到文件。
src/vs/workbench/contrib/notebook/browser/contrib/notebookActions.ts
浏览文件 @
24c65476
...
...
@@ -154,7 +154,7 @@ registerAction2(class extends Action2 {
let
activeCell
=
editor
.
getActiveCell
();
if
(
activeCell
)
{
if
(
activeCell
.
cellKind
===
CellKind
.
Markdown
)
{
activeCell
.
state
=
CellState
.
Read
;
activeCell
.
state
=
CellState
.
Preview
;
}
editor
.
focusNotebookCell
(
activeCell
,
false
);
...
...
src/vs/workbench/contrib/notebook/browser/contrib/notebookFindWidget.ts
浏览文件 @
24c65476
...
...
@@ -79,7 +79,7 @@ export class NotebookFindWidget extends SimpleFindWidget {
}
private
revealCellRange
(
cellIndex
:
number
,
matchIndex
:
number
)
{
this
.
_findMatches
[
cellIndex
].
cell
.
state
=
CellState
.
PreviewContent
;
this
.
_findMatches
[
cellIndex
].
cell
.
state
=
CellState
.
Editing
;
this
.
_notebookEditor
.
selectElement
(
this
.
_findMatches
[
cellIndex
].
cell
);
this
.
_notebookEditor
.
setCellSelection
(
this
.
_findMatches
[
cellIndex
].
cell
,
this
.
_findMatches
[
cellIndex
].
matches
[
matchIndex
].
range
);
this
.
_notebookEditor
.
revealRangeInCenterIfOutsideViewport
(
this
.
_findMatches
[
cellIndex
].
cell
,
this
.
_findMatches
[
cellIndex
].
matches
[
matchIndex
].
range
);
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
24c65476
...
...
@@ -206,14 +206,7 @@ export enum CellState {
* For markdown cell, it's Markdown preview.
* For code cell, the browser focus should be on the container instead of the editor
*/
Read
,
/**
* Content preview mode.
* For markdown cell, the source is now rendered in the editor. When the cell is not longer focsued/selected, it will fall back to Read mode.
* For code cell, this state is the same as Editing
*/
PreviewContent
,
Preview
,
/**
* Eding mode. Source for markdown or code is rendered in editors and the state will be persistent.
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
24c65476
...
...
@@ -579,7 +579,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
}
saveNotebookCell
(
cell
:
CellViewModel
):
void
{
cell
.
state
=
CellState
.
Read
;
cell
.
state
=
CellState
.
Preview
;
}
getActiveCell
()
{
...
...
@@ -600,7 +600,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
this
.
list
?.
setSelection
([
index
]);
this
.
list
?.
focusView
();
cell
.
state
=
CellState
.
PreviewContent
;
cell
.
state
=
CellState
.
Editing
;
cell
.
focusMode
=
CellFocusMode
.
Editor
;
}
else
{
let
itemDOM
=
this
.
list
?.
domElementAtIndex
(
index
);
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
浏览文件 @
24c65476
...
...
@@ -10,7 +10,7 @@ import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
getResizesObserver
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/sizeObserver
'
;
import
{
CELL_MARGIN
,
EDITOR_TOP_PADDING
,
EDITOR_BOTTOM_PADDING
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookEditor
,
CellRenderTemplate
,
CellFocusMode
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
INotebookEditor
,
CellRenderTemplate
,
CellFocusMode
,
CellState
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
raceCancellation
}
from
'
vs/base/common/async
'
;
...
...
@@ -36,7 +36,7 @@ export class StatefullMarkdownCell extends Disposable {
this
.
_register
(
this
.
localDisposables
);
const
viewUpdate
=
()
=>
{
if
(
viewCell
.
is
Editing
)
{
if
(
viewCell
.
state
===
CellState
.
Editing
)
{
// switch to editing mode
let
width
:
number
;
const
listDimension
=
notebookEditor
.
getLayoutInfo
();
...
...
@@ -106,7 +106,7 @@ export class StatefullMarkdownCell extends Disposable {
notebookEditor
.
layoutNotebookCell
(
viewCell
,
this
.
editor
!
.
getContentHeight
()
+
32
+
clientHeight
);
}));
if
(
viewCell
.
is
Editing
)
{
if
(
viewCell
.
state
===
CellState
.
Editing
)
{
this
.
editor
!
.
focus
();
}
});
...
...
@@ -189,7 +189,7 @@ export class StatefullMarkdownCell extends Disposable {
}
};
this
.
_register
(
viewCell
.
onDidChange
Editing
State
(()
=>
{
this
.
_register
(
viewCell
.
onDidChange
Cell
State
(()
=>
{
this
.
localDisposables
.
clear
();
viewUpdate
();
}));
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/notebookCellViewModel.ts
浏览文件 @
24c65476
...
...
@@ -24,8 +24,8 @@ export class CellViewModel extends Disposable {
private
_html
:
HTMLElement
|
null
=
null
;
protected
readonly
_onDidDispose
=
new
Emitter
<
void
>
();
readonly
onDidDispose
=
this
.
_onDidDispose
.
event
;
protected
readonly
_onDidChange
Editing
State
=
new
Emitter
<
void
>
();
readonly
onDidChange
EditingState
=
this
.
_onDidChangeEditing
State
.
event
;
protected
readonly
_onDidChange
Cell
State
=
new
Emitter
<
void
>
();
readonly
onDidChange
CellState
=
this
.
_onDidChangeCell
State
.
event
;
protected
readonly
_onDidChangeFocusMode
=
new
Emitter
<
void
>
();
readonly
onDidChangeFocusMode
=
this
.
_onDidChangeFocusMode
.
event
;
protected
readonly
_onDidChangeOutputs
=
new
Emitter
<
NotebookCellOutputsSplice
[]
>
();
...
...
@@ -47,33 +47,19 @@ export class CellViewModel extends Disposable {
return
this
.
cell
.
outputs
;
}
private
_isEditing
:
boolean
;
get
isEditing
():
boolean
{
return
this
.
_isEditing
;
}
private
_state
:
CellState
=
CellState
.
Read
;
private
_state
:
CellState
=
CellState
.
Preview
;
get
state
():
CellState
{
return
this
.
_state
;
}
set
state
(
newState
:
CellState
)
{
// no downgrade from Editing to PreviewContent
if
(
this
.
_state
===
CellState
.
Editing
&&
newState
===
CellState
.
PreviewContent
)
{
if
(
newState
===
this
.
_state
)
{
return
;
}
this
.
_state
=
newState
;
if
(
newState
!==
CellState
.
Read
)
{
this
.
_isEditing
=
true
;
}
else
{
this
.
_isEditing
=
false
;
}
this
.
_onDidChangeEditingState
.
fire
();
this
.
_onDidChangeCellState
.
fire
();
}
private
_focusMode
:
CellFocusMode
=
CellFocusMode
.
Container
;
...
...
@@ -145,7 +131,6 @@ export class CellViewModel extends Disposable {
this
.
_outputCollection
=
new
Array
(
this
.
cell
.
outputs
.
length
);
this
.
_buffer
=
null
;
this
.
_editorViewStates
=
null
;
this
.
_isEditing
=
false
;
}
restoreEditorViewState
(
editorViewStates
:
editorCommon
.
ICodeEditorViewState
|
null
)
{
...
...
@@ -252,7 +237,7 @@ export class CellViewModel extends Disposable {
this
.
_html
=
null
;
}
save
()
{
if
(
this
.
_textModel
&&
!
this
.
_textModel
.
isDisposed
()
&&
(
this
.
cell
.
isDirty
||
this
.
is
Editing
))
{
if
(
this
.
_textModel
&&
!
this
.
_textModel
.
isDisposed
()
&&
(
this
.
cell
.
isDirty
||
this
.
state
===
CellState
.
Editing
))
{
let
cnt
=
this
.
_textModel
.
getLineCount
();
this
.
cell
.
source
=
this
.
_textModel
.
getLinesContent
().
map
((
str
,
index
)
=>
str
+
(
index
!==
cnt
-
1
?
'
\n
'
:
''
));
}
...
...
@@ -393,11 +378,7 @@ export class CellViewModel extends Disposable {
}
onDeselect
()
{
if
(
this
.
cellKind
===
CellKind
.
Code
)
{
this
.
state
=
CellState
.
Read
;
}
else
if
(
this
.
state
===
CellState
.
PreviewContent
)
{
this
.
state
=
CellState
.
Read
;
}
this
.
state
=
CellState
.
Preview
;
}
cursorAtBoundary
():
CursorAtBoundary
{
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
浏览文件 @
24c65476
...
...
@@ -89,7 +89,7 @@ export class NotebookViewModel extends Disposable {
hide
()
{
this
.
viewCells
.
forEach
(
cell
=>
{
if
(
cell
.
getText
()
!==
''
)
{
cell
.
state
=
CellState
.
Read
;
cell
.
state
=
CellState
.
Preview
;
}
});
}
...
...
@@ -131,7 +131,7 @@ export class NotebookViewModel extends Disposable {
saveEditorViewState
():
INotebookEditorViewState
{
const
state
:
{
[
key
:
number
]:
boolean
}
=
{};
this
.
viewCells
.
filter
(
cell
=>
cell
.
is
Editing
).
forEach
(
cell
=>
state
[
cell
.
cell
.
handle
]
=
true
);
this
.
viewCells
.
filter
(
cell
=>
cell
.
state
===
CellState
.
Editing
).
forEach
(
cell
=>
state
[
cell
.
cell
.
handle
]
=
true
);
const
editorViewStates
:
{
[
key
:
number
]:
editorCommon
.
ICodeEditorViewState
}
=
{};
this
.
viewCells
.
map
(
cell
=>
({
handle
:
cell
.
cell
.
handle
,
state
:
cell
.
saveEditorViewState
()
})).
forEach
(
viewState
=>
{
if
(
viewState
.
state
)
{
...
...
@@ -154,7 +154,7 @@ export class NotebookViewModel extends Disposable {
const
isEditing
=
viewState
.
editingCells
&&
viewState
.
editingCells
[
cell
.
handle
];
const
editorViewState
=
viewState
.
editorViewStates
&&
viewState
.
editorViewStates
[
cell
.
handle
];
cell
.
state
=
isEditing
?
CellState
.
Editing
:
CellState
.
Read
;
cell
.
state
=
isEditing
?
CellState
.
Editing
:
CellState
.
Preview
;
cell
.
restoreEditorViewState
(
editorViewState
);
});
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录