Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
ad22aa2f
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,发现更多精彩内容 >>
提交
ad22aa2f
编写于
3月 05, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
save & restore all editor view states
上级
a4a17ae7
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
20 addition
and
82 deletion
+20
-82
src/vs/workbench/contrib/notebook/browser/notebookViewModel.ts
...s/workbench/contrib/notebook/browser/notebookViewModel.ts
+8
-7
src/vs/workbench/contrib/notebook/browser/renderers/cellViewModel.ts
...bench/contrib/notebook/browser/renderers/cellViewModel.ts
+12
-75
未找到文件。
src/vs/workbench/contrib/notebook/browser/notebookViewModel.ts
浏览文件 @
ad22aa2f
...
...
@@ -3,17 +3,18 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
NotebookEditorModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookEditorInput
'
;
import
{
CellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/renderers/cellViewModel
'
;
import
{
DisposableStore
,
Disposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
NotebookCellsSplice
,
ICellEditorViewState
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
Disposable
,
DisposableStore
}
from
'
vs/base/common/lifecycle
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
NotebookEditorModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookEditorInput
'
;
import
{
CellFindMatch
}
from
'
vs/workbench/contrib/notebook/browser/notebookFindWidget
'
;
import
{
CellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/renderers/cellViewModel
'
;
import
{
NotebookCellsSplice
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
export
interface
INotebookEditorViewState
{
editingCells
:
{
[
key
:
number
]:
boolean
};
editorViewStates
:
{
[
key
:
number
]:
ICellEditorViewState
};
editorViewStates
:
{
[
key
:
number
]:
editorCommon
.
ICodeEditorViewState
|
null
};
}
export
class
NotebookViewModel
extends
Disposable
{
...
...
@@ -102,7 +103,7 @@ export class NotebookViewModel extends Disposable {
saveEditorViewState
():
INotebookEditorViewState
{
const
state
:
{
[
key
:
number
]:
boolean
}
=
{};
this
.
viewCells
.
filter
(
cell
=>
cell
.
isEditing
).
forEach
(
cell
=>
state
[
cell
.
cell
.
handle
]
=
true
);
const
editorViewStates
:
{
[
key
:
number
]:
ICell
EditorViewState
}
=
{};
const
editorViewStates
:
{
[
key
:
number
]:
editorCommon
.
ICode
EditorViewState
}
=
{};
this
.
viewCells
.
map
(
cell
=>
({
handle
:
cell
.
cell
.
handle
,
state
:
cell
.
saveEditorViewState
()
})).
forEach
(
viewState
=>
{
if
(
viewState
.
state
)
{
editorViewStates
[
viewState
.
handle
]
=
viewState
.
state
;
...
...
src/vs/workbench/contrib/notebook/browser/renderers/cellViewModel.ts
浏览文件 @
ad22aa2f
...
...
@@ -8,7 +8,6 @@ import { Disposable } from 'vs/base/common/lifecycle';
import
*
as
UUID
from
'
vs/base/common/uuid
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
import
{
Range
}
from
'
vs/editor/common/core/range
'
;
import
{
ISelection
}
from
'
vs/editor/common/core/selection
'
;
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
SearchParams
}
from
'
vs/editor/common/model/textModelSearch
'
;
...
...
@@ -17,7 +16,7 @@ import { PrefixSumComputer } from 'vs/editor/common/viewModel/prefixSumComputer'
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
CellFindMatch
}
from
'
vs/workbench/contrib/notebook/browser/notebookFindWidget
'
;
import
{
MarkdownRenderer
}
from
'
vs/workbench/contrib/notebook/browser/renderers/mdRenderer
'
;
import
{
CellKind
,
EDITOR_BOTTOM_PADDING
,
EDITOR_TOP_PADDING
,
ICell
,
I
CellEditorViewState
,
I
Output
,
NotebookCellOutputsSplice
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
EDITOR_BOTTOM_PADDING
,
EDITOR_TOP_PADDING
,
ICell
,
IOutput
,
NotebookCellOutputsSplice
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
export
class
CellViewModel
extends
Disposable
{
...
...
@@ -78,7 +77,7 @@ export class CellViewModel extends Disposable {
private
_textModel
?:
model
.
ITextModel
;
private
_textEditor
?:
ICodeEditor
;
private
_buffer
:
model
.
ITextBuffer
|
null
;
private
_editorViewStates
:
ICell
EditorViewState
|
null
;
private
_editorViewStates
:
editorCommon
.
ICode
EditorViewState
|
null
;
readonly
id
:
string
=
UUID
.
generateUuid
();
...
...
@@ -104,15 +103,13 @@ export class CellViewModel extends Disposable {
this
.
_isEditing
=
false
;
}
restoreEditorViewState
(
editorViewStates
:
ICellEditorViewState
)
{
restoreEditorViewState
(
editorViewStates
:
editorCommon
.
ICodeEditorViewState
|
null
)
{
this
.
_editorViewStates
=
editorViewStates
;
}
saveEditorViewState
()
{
if
(
this
.
_textEditor
)
{
this
.
_editorViewStates
=
{
selections
:
this
.
saveViewState
()
};
this
.
_editorViewStates
=
this
.
saveViewState
();
}
return
this
.
_editorViewStates
;
...
...
@@ -167,77 +164,19 @@ export class CellViewModel extends Disposable {
return
false
;
}
private
saveViewState
():
editorCommon
.
IC
ursorState
[]
{
private
saveViewState
():
editorCommon
.
IC
odeEditorViewState
|
null
{
if
(
!
this
.
_textEditor
)
{
return
[]
;
return
null
;
}
let
result
:
editorCommon
.
ICursorState
[]
=
[];
const
selections
=
this
.
_textEditor
.
getSelections
();
if
(
!
selections
)
{
return
[];
}
for
(
let
i
=
0
,
len
=
selections
.
length
;
i
<
len
;
i
++
)
{
const
selection
=
selections
[
i
];
result
.
push
({
inSelectionMode
:
!
selection
.
isEmpty
(),
selectionStart
:
{
lineNumber
:
selection
.
selectionStartLineNumber
,
column
:
selection
.
selectionStartColumn
,
},
position
:
{
lineNumber
:
selection
.
positionLineNumber
,
column
:
selection
.
positionColumn
,
}
});
}
return
result
;
return
this
.
_textEditor
.
saveViewState
();
}
private
restoreViewState
(
states
:
editorCommon
.
ICursorState
[]):
void
{
let
desiredSelections
:
ISelection
[]
=
[];
for
(
let
i
=
0
,
len
=
states
.
length
;
i
<
len
;
i
++
)
{
const
state
=
states
[
i
];
let
positionLineNumber
=
1
;
let
positionColumn
=
1
;
// Avoid missing properties on the literal
if
(
state
.
position
&&
state
.
position
.
lineNumber
)
{
positionLineNumber
=
state
.
position
.
lineNumber
;
}
if
(
state
.
position
&&
state
.
position
.
column
)
{
positionColumn
=
state
.
position
.
column
;
}
let
selectionStartLineNumber
=
positionLineNumber
;
let
selectionStartColumn
=
positionColumn
;
// Avoid missing properties on the literal
if
(
state
.
selectionStart
&&
state
.
selectionStart
.
lineNumber
)
{
selectionStartLineNumber
=
state
.
selectionStart
.
lineNumber
;
}
if
(
state
.
selectionStart
&&
state
.
selectionStart
.
column
)
{
selectionStartColumn
=
state
.
selectionStart
.
column
;
}
desiredSelections
.
push
({
selectionStartLineNumber
:
selectionStartLineNumber
,
selectionStartColumn
:
selectionStartColumn
,
positionLineNumber
:
positionLineNumber
,
positionColumn
:
positionColumn
});
private
restoreViewState
(
state
:
editorCommon
.
ICodeEditorViewState
|
null
):
void
{
if
(
state
)
{
this
.
_textEditor
?.
restoreViewState
(
state
);
}
this
.
_textEditor
?.
setSelections
(
desiredSelections
);
}
//#endregion
...
...
@@ -318,14 +257,12 @@ export class CellViewModel extends Disposable {
this
.
_textEditor
=
editor
;
if
(
this
.
_editorViewStates
)
{
this
.
restoreViewState
(
this
.
_editorViewStates
.
selections
);
this
.
restoreViewState
(
this
.
_editorViewStates
);
}
}
detachTextEditor
()
{
this
.
_editorViewStates
=
{
selections
:
this
.
saveViewState
()
};
this
.
_editorViewStates
=
this
.
saveViewState
();
this
.
_textEditor
=
undefined
;
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录