Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
5121bac4
V
vscode
项目概览
掘金者说
/
vscode
与 Fork 源项目一致
从无法访问的项目Fork
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
V
vscode
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
5121bac4
编写于
4月 22, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
NotebookEditor.selection
上级
8b7ea333
变更
7
隐藏空白更改
内联
并排
Showing
7 changed file
with
77 addition
and
1 deletion
+77
-1
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+8
-0
src/vs/workbench/api/browser/mainThreadNotebook.ts
src/vs/workbench/api/browser/mainThreadNotebook.ts
+4
-0
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+10
-0
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+22
-1
src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts
...rkbench/contrib/notebook/browser/view/notebookCellList.ts
+9
-0
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
...h/contrib/notebook/browser/viewModel/notebookViewModel.ts
+11
-0
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
...kbench/contrib/notebook/common/model/notebookTextModel.ts
+13
-0
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
5121bac4
...
...
@@ -1688,7 +1688,15 @@ declare module 'vscode' {
}
export
interface
NotebookEditor
{
/**
* The document associated with this notebook editor.
*/
readonly
document
:
NotebookDocument
;
/**
* The primary selected cell on this notebook editor.
*/
readonly
selection
?:
NotebookCell
;
viewColumn
?:
ViewColumn
;
/**
* Fired when the output hosting webview posts a message.
...
...
src/vs/workbench/api/browser/mainThreadNotebook.ts
浏览文件 @
5121bac4
...
...
@@ -33,6 +33,10 @@ export class MainThreadNotebookDocument extends Disposable {
this
.
_register
(
this
.
_textModel
.
onDidModelChange
(
e
=>
{
this
.
_proxy
.
$acceptModelChanged
(
this
.
uri
,
e
);
}));
this
.
_register
(
this
.
_textModel
.
onDidSelectionChange
(
e
=>
{
const
selectionsChange
=
e
?
{
selections
:
e
}
:
null
;
this
.
_proxy
.
$acceptEditorPropertiesChanged
(
uri
,
{
selections
:
selectionsChange
});
}));
}
applyEdit
(
modelVersionId
:
number
,
edits
:
ICellEditOperation
[]):
boolean
{
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
5121bac4
...
...
@@ -1528,6 +1528,15 @@ export interface ExtHostCommentsShape {
$toggleReaction
(
commentControllerHandle
:
number
,
threadHandle
:
number
,
uri
:
UriComponents
,
comment
:
modes
.
Comment
,
reaction
:
modes
.
CommentReaction
):
Promise
<
void
>
;
}
export
interface
INotebookSelectionChangeEvent
{
// handles
selections
:
number
[];
}
export
interface
INotebookEditorPropertiesChangeData
{
selections
:
INotebookSelectionChangeEvent
|
null
;
}
export
interface
ExtHostNotebookShape
{
$resolveNotebook
(
viewType
:
string
,
uri
:
UriComponents
):
Promise
<
number
|
undefined
>
;
$executeNotebook
(
viewType
:
string
,
uri
:
UriComponents
,
cellHandle
:
number
|
undefined
,
token
:
CancellationToken
):
Promise
<
void
>
;
...
...
@@ -1537,6 +1546,7 @@ export interface ExtHostNotebookShape {
$acceptDisplayOrder
(
displayOrder
:
INotebookDisplayOrder
):
void
;
$onDidReceiveMessage
(
uri
:
UriComponents
,
message
:
any
):
void
;
$acceptModelChanged
(
uriComponents
:
UriComponents
,
event
:
NotebookCellsChangedEvent
):
void
;
$acceptEditorPropertiesChanged
(
uriComponents
:
UriComponents
,
data
:
INotebookEditorPropertiesChangeData
):
void
;
}
export
interface
ExtHostStorageShape
{
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
5121bac4
...
...
@@ -10,7 +10,7 @@ import { Disposable, DisposableStore, IDisposable } from 'vs/base/common/lifecyc
import
{
ISplice
}
from
'
vs/base/common/sequence
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
CellKind
,
CellOutputKind
,
ExtHostNotebookShape
,
IMainContext
,
MainContext
,
MainThreadNotebookShape
,
NotebookCellOutputsSplice
,
MainThreadDocumentsShape
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
CellKind
,
CellOutputKind
,
ExtHostNotebookShape
,
IMainContext
,
MainContext
,
MainThreadNotebookShape
,
NotebookCellOutputsSplice
,
MainThreadDocumentsShape
,
INotebookEditorPropertiesChangeData
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostCommands
}
from
'
vs/workbench/api/common/extHostCommands
'
;
import
{
ExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
import
{
CellEditType
,
CellUri
,
diff
,
ICellEditOperation
,
ICellInsertEdit
,
IErrorOutput
,
INotebookDisplayOrder
,
INotebookEditData
,
IOrderedMimeType
,
IStreamOutput
,
ITransformedDisplayOutputDto
,
mimeTypeSupportedByCore
,
NotebookCellsChangedEvent
,
NotebookCellsSplice2
,
sortMimeTypes
,
ICellDeleteEdit
,
notebookDocumentMetadataDefaults
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
...
...
@@ -459,6 +459,8 @@ export class NotebookEditorCellEdit {
export
class
ExtHostNotebookEditor
extends
Disposable
implements
vscode
.
NotebookEditor
{
private
_viewColumn
:
vscode
.
ViewColumn
|
undefined
;
selection
?:
ExtHostCell
=
undefined
;
onDidReceiveMessage
:
vscode
.
Event
<
any
>
=
this
.
_onDidReceiveMessage
.
event
;
constructor
(
...
...
@@ -804,4 +806,23 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
}
}
$acceptEditorPropertiesChanged
(
uriComponents
:
UriComponents
,
data
:
INotebookEditorPropertiesChangeData
):
void
{
let
editor
=
this
.
_editors
.
get
(
URI
.
revive
(
uriComponents
).
toString
());
if
(
!
editor
)
{
return
;
}
if
(
data
.
selections
)
{
const
cells
=
editor
.
editor
.
document
.
cells
;
if
(
data
.
selections
.
selections
.
length
)
{
const
firstCell
=
data
.
selections
.
selections
[
0
];
editor
.
editor
.
selection
=
cells
.
find
(
cell
=>
cell
.
handle
===
firstCell
);
}
else
{
editor
.
editor
.
selection
=
undefined
;
}
}
}
}
src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts
浏览文件 @
5121bac4
...
...
@@ -344,6 +344,7 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
this
.
setFocus
([
index
]);
}
}
selectElement
(
cell
:
ICellViewModel
)
{
const
index
=
this
.
_getViewIndexUpperBound
(
cell
);
...
...
@@ -353,6 +354,14 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
}
}
setFocus
(
indexes
:
number
[],
browserEvent
?:
UIEvent
):
void
{
if
(
this
.
_viewModel
)
{
this
.
_viewModel
.
selections
=
indexes
.
map
(
index
=>
this
.
element
(
index
)).
map
(
cell
=>
cell
.
handle
);
}
super
.
setFocus
(
indexes
,
browserEvent
);
}
revealElementInView
(
cell
:
ICellViewModel
)
{
const
index
=
this
.
_getViewIndexUpperBound
(
cell
);
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel.ts
浏览文件 @
5121bac4
...
...
@@ -197,6 +197,17 @@ export class NotebookViewModel extends Disposable implements EditorFoldingStateD
return
this
.
_layoutInfo
;
}
private
_selections
:
number
[]
=
[];
get
selections
()
{
return
this
.
_selections
;
}
set
selections
(
selections
:
number
[])
{
this
.
_selections
=
selections
;
this
.
_model
.
notebook
.
selections
=
selections
;
}
private
_decorationsTree
=
new
DecorationsTree
();
private
_decorations
:
{
[
decorationId
:
string
]:
IntervalNode
;
}
=
Object
.
create
(
null
);
private
_lastDecorationId
:
number
=
0
;
...
...
src/vs/workbench/contrib/notebook/common/model/notebookTextModel.ts
浏览文件 @
5121bac4
...
...
@@ -18,6 +18,8 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
get
onDidChangeCells
():
Event
<
NotebookCellTextModelSplice
[]
>
{
return
this
.
_onDidChangeCells
.
event
;
}
private
_onDidModelChangeProxy
=
new
Emitter
<
NotebookCellsChangedEvent
>
();
get
onDidModelChange
():
Event
<
NotebookCellsChangedEvent
>
{
return
this
.
_onDidModelChangeProxy
.
event
;
}
private
_onDidSelectionChangeProxy
=
new
Emitter
<
number
[]
|
null
>
();
get
onDidSelectionChange
():
Event
<
number
[]
|
null
>
{
return
this
.
_onDidSelectionChangeProxy
.
event
;
}
private
_onDidChangeContent
=
new
Emitter
<
void
>
();
onDidChangeContent
:
Event
<
void
>
=
this
.
_onDidChangeContent
.
event
;
private
_onDidChangeMetadata
=
new
Emitter
<
NotebookDocumentMetadata
>
();
...
...
@@ -35,6 +37,17 @@ export class NotebookTextModel extends Disposable implements INotebookTextModel
return
this
.
_versionId
;
}
private
_selections
:
number
[]
=
[];
get
selections
()
{
return
this
.
_selections
;
}
set
selections
(
selections
:
number
[])
{
this
.
_selections
=
selections
;
this
.
_onDidSelectionChangeProxy
.
fire
(
this
.
_selections
);
}
constructor
(
public
handle
:
number
,
public
viewType
:
string
,
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录