Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
6db3625e
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,发现更多精彩内容 >>
提交
6db3625e
编写于
2月 18, 2020
作者:
J
Johannes Rieken
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ICell#uri and expose INotebook#viewType
上级
fc460707
变更
6
隐藏空白更改
内联
并排
Showing
6 changed file
with
24 addition
and
28 deletion
+24
-28
src/vs/workbench/api/browser/mainThreadNotebook.ts
src/vs/workbench/api/browser/mainThreadNotebook.ts
+11
-2
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
...rkbench/contrib/notebook/browser/notebook.contribution.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
+4
-4
src/vs/workbench/contrib/notebook/browser/notebookService.ts
src/vs/workbench/contrib/notebook/browser/notebookService.ts
+3
-18
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+2
-0
未找到文件。
src/vs/workbench/api/browser/mainThreadNotebook.ts
浏览文件 @
6db3625e
...
@@ -41,7 +41,10 @@ export class MainThreadCell implements ICell {
...
@@ -41,7 +41,10 @@ export class MainThreadCell implements ICell {
this
.
_onDidChangeDirtyState
.
fire
(
newState
);
this
.
_onDidChangeDirtyState
.
fire
(
newState
);
}
}
readonly
uri
:
URI
;
constructor
(
constructor
(
parent
:
MainThreadNotebookDocument
,
public
handle
:
number
,
public
handle
:
number
,
public
source
:
string
[],
public
source
:
string
[],
public
language
:
string
,
public
language
:
string
,
...
@@ -49,6 +52,12 @@ export class MainThreadCell implements ICell {
...
@@ -49,6 +52,12 @@ export class MainThreadCell implements ICell {
outputs
:
IOutput
[]
outputs
:
IOutput
[]
)
{
)
{
this
.
_outputs
=
outputs
;
this
.
_outputs
=
outputs
;
this
.
uri
=
URI
.
from
({
scheme
:
'
vscode-notebook
'
,
authority
:
parent
.
viewType
,
path
:
`/cell_
${
handle
}
.
${
cell_type
===
'
markdown
'
?
'
md
'
:
'
py
'
}
`
,
query
:
parent
.
uri
.
toString
()
});
}
}
save
()
{
save
()
{
...
@@ -114,7 +123,7 @@ export class MainThreadNotebookDocument extends Disposable implements INotebook
...
@@ -114,7 +123,7 @@ export class MainThreadNotebookDocument extends Disposable implements INotebook
if
(
this
.
cells
.
length
===
0
)
{
if
(
this
.
cells
.
length
===
0
)
{
newCells
.
forEach
(
cell
=>
{
newCells
.
forEach
(
cell
=>
{
let
mainCell
=
new
MainThreadCell
(
cell
.
handle
,
cell
.
source
,
cell
.
language
,
cell
.
cell_type
,
cell
.
outputs
);
let
mainCell
=
new
MainThreadCell
(
this
,
cell
.
handle
,
cell
.
source
,
cell
.
language
,
cell
.
cell_type
,
cell
.
outputs
);
this
.
_mapping
.
set
(
cell
.
handle
,
mainCell
);
this
.
_mapping
.
set
(
cell
.
handle
,
mainCell
);
this
.
cells
.
push
(
mainCell
);
this
.
cells
.
push
(
mainCell
);
let
dirtyStateListener
=
mainCell
.
onDidChangeDirtyState
((
cellState
)
=>
{
let
dirtyStateListener
=
mainCell
.
onDidChangeDirtyState
((
cellState
)
=>
{
...
@@ -141,7 +150,7 @@ export class MainThreadNotebookDocument extends Disposable implements INotebook
...
@@ -141,7 +150,7 @@ export class MainThreadNotebookDocument extends Disposable implements INotebook
async
createRawCell
(
viewType
:
string
,
uri
:
URI
,
index
:
number
,
language
:
string
,
type
:
'
markdown
'
|
'
code
'
):
Promise
<
MainThreadCell
|
undefined
>
{
async
createRawCell
(
viewType
:
string
,
uri
:
URI
,
index
:
number
,
language
:
string
,
type
:
'
markdown
'
|
'
code
'
):
Promise
<
MainThreadCell
|
undefined
>
{
let
cell
=
await
this
.
_proxy
.
$createEmptyCell
(
viewType
,
uri
,
index
,
language
,
type
);
let
cell
=
await
this
.
_proxy
.
$createEmptyCell
(
viewType
,
uri
,
index
,
language
,
type
);
if
(
cell
)
{
if
(
cell
)
{
let
mainCell
=
new
MainThreadCell
(
cell
.
handle
,
cell
.
source
,
cell
.
language
,
cell
.
cell_type
,
cell
.
outputs
);
let
mainCell
=
new
MainThreadCell
(
this
,
cell
.
handle
,
cell
.
source
,
cell
.
language
,
cell
.
cell_type
,
cell
.
outputs
);
this
.
_mapping
.
set
(
cell
.
handle
,
mainCell
);
this
.
_mapping
.
set
(
cell
.
handle
,
mainCell
);
this
.
cells
.
splice
(
index
,
0
,
mainCell
);
this
.
cells
.
splice
(
index
,
0
,
mainCell
);
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
6db3625e
...
@@ -5,7 +5,7 @@
...
@@ -5,7 +5,7 @@
import
*
as
vscode
from
'
vscode
'
;
import
*
as
vscode
from
'
vscode
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
*
as
glob
from
'
vs/base/common/glob
'
;
import
{
ExtHostNotebookShape
,
IMainContext
,
MainThreadNotebookShape
,
MainContext
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
ExtHostNotebookShape
,
IMainContext
,
MainThreadNotebookShape
,
MainContext
,
ICellDto
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
IExtensionDescription
}
from
'
vs/platform/extensions/common/extensions
'
;
import
{
Disposable
as
VSCodeDisposable
}
from
'
./extHostTypes
'
;
import
{
Disposable
as
VSCodeDisposable
}
from
'
./extHostTypes
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
import
{
URI
,
UriComponents
}
from
'
vs/base/common/uri
'
;
...
@@ -13,7 +13,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
...
@@ -13,7 +13,7 @@ import { DisposableStore } from 'vs/base/common/lifecycle';
import
{
readonly
}
from
'
vs/base/common/errors
'
;
import
{
readonly
}
from
'
vs/base/common/errors
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
ExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
import
{
ExtHostDocumentsAndEditors
}
from
'
vs/workbench/api/common/extHostDocumentsAndEditors
'
;
import
{
I
Cell
,
I
NotebookDisplayOrder
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookDisplayOrder
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
interface
ExtHostOutputDisplayOrder
{
interface
ExtHostOutputDisplayOrder
{
defaultOrder
:
glob
.
ParsedPattern
[];
defaultOrder
:
glob
.
ParsedPattern
[];
...
@@ -500,7 +500,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
...
@@ -500,7 +500,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
return
provider
.
provider
.
executeCell
(
document
!
,
cell
);
return
provider
.
provider
.
executeCell
(
document
!
,
cell
);
}
}
async
$createEmptyCell
(
viewType
:
string
,
uri
:
URI
,
index
:
number
,
language
:
string
,
type
:
'
markdown
'
|
'
code
'
):
Promise
<
ICell
|
undefined
>
{
async
$createEmptyCell
(
viewType
:
string
,
uri
:
URI
,
index
:
number
,
language
:
string
,
type
:
'
markdown
'
|
'
code
'
):
Promise
<
ICell
Dto
|
undefined
>
{
let
provider
=
this
.
_notebookProviders
.
get
(
viewType
);
let
provider
=
this
.
_notebookProviders
.
get
(
viewType
);
if
(
provider
)
{
if
(
provider
)
{
...
...
src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
浏览文件 @
6db3625e
...
@@ -121,7 +121,7 @@ class CellContentProvider implements ITextModelContentProvider {
...
@@ -121,7 +121,7 @@ class CellContentProvider implements ITextModelContentProvider {
return
null
;
return
null
;
}
}
for
(
let
cell
of
notebook
.
cells
)
{
for
(
let
cell
of
notebook
.
cells
)
{
if
(
cell
.
handle
===
data
.
cellHandle
)
{
if
(
cell
.
uri
.
toString
()
===
resource
.
toString
()
)
{
return
this
.
_modelService
.
createModel
(
return
this
.
_modelService
.
createModel
(
cell
.
source
.
join
(
'
\n
'
),
cell
.
source
.
join
(
'
\n
'
),
this
.
_modeService
.
createByFilepathOrFirstLine
(
resource
,
cell
.
source
[
0
]),
this
.
_modeService
.
createByFilepathOrFirstLine
(
resource
,
cell
.
source
[
0
]),
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditor.ts
浏览文件 @
6db3625e
...
@@ -24,7 +24,7 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
...
@@ -24,7 +24,7 @@ import { BaseEditor } from 'vs/workbench/browser/parts/editor/baseEditor';
import
{
EditorOptions
,
IEditorMemento
,
IEditorControl
}
from
'
vs/workbench/common/editor
'
;
import
{
EditorOptions
,
IEditorMemento
,
IEditorControl
}
from
'
vs/workbench/common/editor
'
;
import
{
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
NotebookEditorInput
,
NotebookEditorModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookEditorInput
'
;
import
{
NotebookEditorInput
,
NotebookEditorModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookEditorInput
'
;
import
{
INotebookService
,
createCellUri
,
parseCellUri
}
from
'
vs/workbench/contrib/notebook/browser/notebookService
'
;
import
{
INotebookService
,
parseCellUri
}
from
'
vs/workbench/contrib/notebook/browser/notebookService
'
;
import
{
OutputRenderer
}
from
'
vs/workbench/contrib/notebook/browser/output/outputRenderer
'
;
import
{
OutputRenderer
}
from
'
vs/workbench/contrib/notebook/browser/output/outputRenderer
'
;
import
{
BackLayerWebView
}
from
'
vs/workbench/contrib/notebook/browser/renderers/backLayerWebView
'
;
import
{
BackLayerWebView
}
from
'
vs/workbench/contrib/notebook/browser/renderers/backLayerWebView
'
;
import
{
CodeCellRenderer
,
MarkdownCellRenderer
,
NotebookCellListDelegate
}
from
'
vs/workbench/contrib/notebook/browser/renderers/cellRenderer
'
;
import
{
CodeCellRenderer
,
MarkdownCellRenderer
,
NotebookCellListDelegate
}
from
'
vs/workbench/contrib/notebook/browser/renderers/cellRenderer
'
;
...
@@ -160,7 +160,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
...
@@ -160,7 +160,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
if
(
data
&&
that
.
notebook
?.
uri
.
toString
()
===
data
.
notebook
.
toString
())
{
if
(
data
&&
that
.
notebook
?.
uri
.
toString
()
===
data
.
notebook
.
toString
())
{
for
(
let
i
=
0
;
i
<
that
.
list
!
.
length
;
i
++
)
{
for
(
let
i
=
0
;
i
<
that
.
list
!
.
length
;
i
++
)
{
const
item
=
that
.
list
!
.
element
(
i
);
const
item
=
that
.
list
!
.
element
(
i
);
if
(
item
.
cell
.
handle
===
data
.
cellHandle
)
{
if
(
item
.
cell
.
uri
.
toString
()
===
input
.
resource
.
toString
()
)
{
that
.
list
!
.
reveal
(
i
,
0.2
);
that
.
list
!
.
reveal
(
i
,
0.2
);
const
editor
=
that
.
renderedEditors
.
get
(
item
);
const
editor
=
that
.
renderedEditors
.
get
(
item
);
if
(
!
editor
)
{
if
(
!
editor
)
{
...
@@ -318,7 +318,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
...
@@ -318,7 +318,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
this
.
webview
.
updateRendererPreloads
(
this
.
notebook
.
renderers
);
this
.
webview
.
updateRendererPreloads
(
this
.
notebook
.
renderers
);
this
.
viewType
=
input
.
viewType
;
this
.
viewType
=
input
.
viewType
;
this
.
viewCells
=
await
Promise
.
all
(
this
.
notebook
!
.
cells
.
map
(
async
cell
=>
{
this
.
viewCells
=
await
Promise
.
all
(
this
.
notebook
!
.
cells
.
map
(
async
cell
=>
{
const
uri
=
c
reateCellUri
(
input
.
viewType
!
,
this
.
notebook
!
,
cell
)
;
const
uri
=
c
ell
.
uri
;
const
ref
=
await
this
.
textModelService
.
createModelReference
(
uri
);
const
ref
=
await
this
.
textModelService
.
createModelReference
(
uri
);
const
isEditing
=
viewState
&&
viewState
.
editingCells
[
cell
.
handle
];
const
isEditing
=
viewState
&&
viewState
.
editingCells
[
cell
.
handle
];
return
this
.
instantiationService
.
createInstance
(
CellViewModel
,
input
.
viewType
!
,
this
.
notebook
!
.
handle
,
cell
,
ref
.
object
.
textEditorModel
,
!!
isEditing
);
return
this
.
instantiationService
.
createInstance
(
CellViewModel
,
input
.
viewType
!
,
this
.
notebook
!
.
handle
,
cell
,
ref
.
object
.
textEditorModel
,
!!
isEditing
);
...
@@ -453,7 +453,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
...
@@ -453,7 +453,7 @@ export class NotebookEditor extends BaseEditor implements INotebookEditor {
const
insertIndex
=
direction
===
'
above
'
?
index
:
index
+
1
;
const
insertIndex
=
direction
===
'
above
'
?
index
:
index
+
1
;
let
newModeCell
=
await
this
.
notebookService
.
createNotebookCell
(
this
.
viewType
!
,
this
.
notebook
!
.
uri
,
insertIndex
,
language
,
type
);
let
newModeCell
=
await
this
.
notebookService
.
createNotebookCell
(
this
.
viewType
!
,
this
.
notebook
!
.
uri
,
insertIndex
,
language
,
type
);
let
uri
=
createCellUri
(
this
.
viewType
!
,
this
.
notebook
!
,
newModeCell
!
)
;
let
uri
=
newModeCell
!
.
uri
;
let
ref
=
await
this
.
textModelService
.
createModelReference
(
uri
);
let
ref
=
await
this
.
textModelService
.
createModelReference
(
uri
);
let
newCell
=
this
.
instantiationService
.
createInstance
(
CellViewModel
,
this
.
viewType
!
,
this
.
notebook
!
.
handle
,
newModeCell
!
,
ref
.
object
.
textEditorModel
,
false
);
let
newCell
=
this
.
instantiationService
.
createInstance
(
CellViewModel
,
this
.
viewType
!
,
this
.
notebook
!
.
handle
,
newModeCell
!
,
ref
.
object
.
textEditorModel
,
false
);
...
...
src/vs/workbench/contrib/notebook/browser/notebookService.ts
浏览文件 @
6db3625e
...
@@ -11,31 +11,16 @@ import { NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/noteb
...
@@ -11,31 +11,16 @@ import { NotebookProviderInfo } from 'vs/workbench/contrib/notebook/common/noteb
import
{
NotebookExtensionDescription
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
NotebookExtensionDescription
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
import
{
INotebook
,
ICell
,
INotebookMimeTypeSelector
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebook
,
ICell
,
INotebookMimeTypeSelector
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
basename
,
extname
}
from
'
vs/base/common/path
'
;
export
function
createCellUri
(
viewType
:
string
,
notebook
:
INotebook
,
cell
:
ICell
):
URI
{
export
function
parseCellUri
(
resource
:
URI
):
{
viewType
:
string
,
notebook
:
URI
}
|
undefined
{
//vscode-notebook://<viewType>/cell_<cellHandle>.ext
// @todo Jo,Peng: `authority` will be transformed to lower case in `URI.toString()`, so we won't retrive the same viewType later on.
return
URI
.
from
({
scheme
:
'
vscode-notebook
'
,
authority
:
viewType
,
path
:
`/cell_
${
cell
.
handle
}
.
${
cell
.
cell_type
===
'
markdown
'
?
'
md
'
:
'
py
'
}
`
,
query
:
notebook
.
uri
.
toString
()
});
}
export
function
parseCellUri
(
resource
:
URI
):
{
viewType
:
string
,
notebook
:
URI
,
cellHandle
:
number
}
|
undefined
{
//vscode-notebook://<viewType>/cell_<cellHandle>.ext
//vscode-notebook://<viewType>/cell_<cellHandle>.ext
if
(
resource
.
scheme
!==
'
vscode-notebook
'
)
{
if
(
resource
.
scheme
!==
'
vscode-notebook
'
)
{
return
undefined
;
return
undefined
;
}
}
const
match
=
/cell_
(\d
+
)
/
.
exec
(
basename
(
resource
.
path
,
extname
(
resource
.
path
)));
// @todo Jo,Peng: `authority` will be transformed to lower case in `URI.toString()`, so we won't retrive the same viewType later on.
if
(
!
match
)
{
return
undefined
;
}
const
viewType
=
resource
.
authority
;
const
viewType
=
resource
.
authority
;
const
notebook
=
URI
.
parse
(
resource
.
query
);
const
notebook
=
URI
.
parse
(
resource
.
query
);
return
{
viewType
,
notebook
,
cellHandle
:
parseInt
(
match
[
1
])
};
return
{
viewType
,
notebook
};
}
}
function
MODEL_ID
(
resource
:
URI
):
string
{
function
MODEL_ID
(
resource
:
URI
):
string
{
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
6db3625e
...
@@ -94,6 +94,7 @@ export type IOutput = IGenericOutput;
...
@@ -94,6 +94,7 @@ export type IOutput = IGenericOutput;
* @internal
* @internal
*/
*/
export
interface
ICell
{
export
interface
ICell
{
readonly
uri
:
URI
;
handle
:
number
;
handle
:
number
;
source
:
string
[];
source
:
string
[];
language
:
string
;
language
:
string
;
...
@@ -122,6 +123,7 @@ export interface IMetadata {
...
@@ -122,6 +123,7 @@ export interface IMetadata {
*/
*/
export
interface
INotebook
{
export
interface
INotebook
{
handle
:
number
;
handle
:
number
;
viewType
:
string
;
// metadata: IMetadata;
// metadata: IMetadata;
readonly
uri
:
URI
;
readonly
uri
:
URI
;
languages
:
string
[];
languages
:
string
[];
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录