Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
e3c3ea27
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,发现更多精彩内容 >>
提交
e3c3ea27
编写于
5月 13, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Switch kernel info.
上级
b353f507
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
139 addition
and
6 deletion
+139
-6
src/vs/vscode.proposed.d.ts
src/vs/vscode.proposed.d.ts
+1
-0
src/vs/workbench/api/browser/mainThreadNotebook.ts
src/vs/workbench/api/browser/mainThreadNotebook.ts
+3
-2
src/vs/workbench/api/common/extHost.protocol.ts
src/vs/workbench/api/common/extHost.protocol.ts
+1
-1
src/vs/workbench/api/common/extHostNotebook.ts
src/vs/workbench/api/common/extHostNotebook.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/contrib/status/editorStatus.ts
...h/contrib/notebook/browser/contrib/status/editorStatus.ts
+125
-0
src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
...rkbench/contrib/notebook/browser/notebook.contribution.ts
+1
-0
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+3
-1
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
+1
-0
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
+3
-1
未找到文件。
src/vs/vscode.proposed.d.ts
浏览文件 @
e3c3ea27
...
...
@@ -1795,6 +1795,7 @@ declare module 'vscode' {
}
export
interface
NotebookKernel
{
label
:
string
;
preloads
?:
Uri
[];
executeCell
(
document
:
NotebookDocument
,
cell
:
NotebookCell
,
token
:
CancellationToken
):
Promise
<
void
>
;
executeAllCells
(
document
:
NotebookDocument
,
token
:
CancellationToken
):
Promise
<
void
>
;
...
...
src/vs/workbench/api/browser/mainThreadNotebook.ts
浏览文件 @
e3c3ea27
...
...
@@ -134,8 +134,8 @@ export class MainThreadNotebooks extends Disposable implements MainThreadNoteboo
return
;
}
async
$registerNotebookKernel
(
extension
:
NotebookExtensionDescription
,
id
:
string
,
selectors
:
(
string
|
IRelativePattern
)[],
preloads
:
UriComponents
[]):
Promise
<
void
>
{
const
kernel
=
new
MainThreadNotebookKernel
(
this
.
_proxy
,
id
,
selectors
,
extension
.
id
,
URI
.
revive
(
extension
.
location
),
preloads
.
map
(
preload
=>
URI
.
revive
(
preload
)));
async
$registerNotebookKernel
(
extension
:
NotebookExtensionDescription
,
id
:
string
,
label
:
string
,
selectors
:
(
string
|
IRelativePattern
)[],
preloads
:
UriComponents
[]):
Promise
<
void
>
{
const
kernel
=
new
MainThreadNotebookKernel
(
this
.
_proxy
,
id
,
label
,
selectors
,
extension
.
id
,
URI
.
revive
(
extension
.
location
),
preloads
.
map
(
preload
=>
URI
.
revive
(
preload
)));
this
.
_notebookKernels
.
set
(
id
,
kernel
);
this
.
_notebookService
.
registerNotebookKernel
(
kernel
);
return
;
...
...
@@ -345,6 +345,7 @@ export class MainThreadNotebookKernel implements INotebookKernelInfo {
constructor
(
private
readonly
_proxy
:
ExtHostNotebookShape
,
readonly
id
:
string
,
readonly
label
:
string
,
readonly
selectors
:
(
string
|
IRelativePattern
)[],
readonly
extension
:
ExtensionIdentifier
,
readonly
extensionLocation
:
URI
,
...
...
src/vs/workbench/api/common/extHost.protocol.ts
浏览文件 @
e3c3ea27
...
...
@@ -693,7 +693,7 @@ export interface MainThreadNotebookShape extends IDisposable {
$unregisterNotebookProvider
(
viewType
:
string
):
Promise
<
void
>
;
$registerNotebookRenderer
(
extension
:
NotebookExtensionDescription
,
type
:
string
,
selectors
:
INotebookMimeTypeSelector
,
handle
:
number
,
preloads
:
UriComponents
[]):
Promise
<
void
>
;
$unregisterNotebookRenderer
(
handle
:
number
):
Promise
<
void
>
;
$registerNotebookKernel
(
extension
:
NotebookExtensionDescription
,
id
:
string
,
selectors
:
(
string
|
IRelativePattern
)[],
preloads
:
UriComponents
[]):
Promise
<
void
>
;
$registerNotebookKernel
(
extension
:
NotebookExtensionDescription
,
id
:
string
,
label
:
string
,
selectors
:
(
string
|
IRelativePattern
)[],
preloads
:
UriComponents
[]):
Promise
<
void
>
;
$unregisterNotebookKernel
(
id
:
string
):
Promise
<
void
>
;
$tryApplyEdits
(
viewType
:
string
,
resource
:
UriComponents
,
modelVersionId
:
number
,
edits
:
ICellEditOperation
[],
renderers
:
number
[]):
Promise
<
boolean
>
;
$updateNotebookLanguages
(
viewType
:
string
,
resource
:
UriComponents
,
languages
:
string
[]):
Promise
<
void
>
;
...
...
src/vs/workbench/api/common/extHostNotebook.ts
浏览文件 @
e3c3ea27
...
...
@@ -731,7 +731,7 @@ export class ExtHostNotebookController implements ExtHostNotebookShape, ExtHostN
this
.
_notebookKernels
.
set
(
id
,
{
kernel
,
extension
});
const
transformedSelectors
=
selectors
.
map
(
selector
=>
typeConverters
.
GlobPattern
.
from
(
selector
));
this
.
_proxy
.
$registerNotebookKernel
({
id
:
extension
.
identifier
,
location
:
extension
.
extensionLocation
},
id
,
transformedSelectors
,
kernel
.
preloads
||
[]);
this
.
_proxy
.
$registerNotebookKernel
({
id
:
extension
.
identifier
,
location
:
extension
.
extensionLocation
},
id
,
kernel
.
label
,
transformedSelectors
,
kernel
.
preloads
||
[]);
return
new
VSCodeDisposable
(()
=>
{
this
.
_notebookKernels
.
delete
(
id
);
this
.
_proxy
.
$unregisterNotebookKernel
(
id
);
...
...
src/vs/workbench/contrib/notebook/browser/contrib/status/editorStatus.ts
0 → 100644
浏览文件 @
e3c3ea27
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
Disposable
,
DisposableStore
,
MutableDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
INotebookEditor
,
NOTEBOOK_EDITOR_FOCUSED
,
NOTEBOOK_IS_ACTIVE_EDITOR
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
IWorkbenchContribution
,
IWorkbenchContributionsRegistry
,
Extensions
as
WorkbenchExtensions
}
from
'
vs/workbench/common/contributions
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
IStatusbarService
,
IStatusbarEntryAccessor
,
IStatusbarEntry
,
StatusbarAlignment
}
from
'
vs/workbench/services/statusbar/common/statusbar
'
;
import
{
IQuickInputService
,
QuickPickInput
,
IQuickPickItem
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
registerAction2
,
Action2
}
from
'
vs/platform/actions/common/actions
'
;
import
{
NOTEBOOK_ACTIONS_CATEGORY
,
INotebookCellActionContext
}
from
'
vs/workbench/contrib/notebook/browser/contrib/coreActions
'
;
import
{
ContextKeyExpr
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
INotebookKernelInfo
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
export
class
NotebookEditorStatus
extends
Disposable
implements
IWorkbenchContribution
{
private
_localStore
:
DisposableStore
=
new
DisposableStore
();
private
kernelInfoElement
=
this
.
_register
(
new
MutableDisposable
<
IStatusbarEntryAccessor
>
());
constructor
(
@
IEditorService
private
readonly
editorService
:
IEditorService
,
@
IStatusbarService
private
readonly
statusbarService
:
IStatusbarService
,
)
{
super
();
this
.
registerListeners
();
}
private
registerListeners
():
void
{
this
.
_register
(
this
.
editorService
.
onDidActiveEditorChange
(()
=>
this
.
updateStatusBar
()));
this
.
updateStatusBar
();
}
private
async
updateStatusBar
():
Promise
<
void
>
{
this
.
_localStore
.
clear
();
const
activeEditorPane
=
this
.
editorService
.
activeEditorPane
as
any
|
undefined
;
if
(
!
activeEditorPane
?.
isNotebookEditor
)
{
this
.
kernelInfoElement
.
clear
();
return
;
}
const
editor
=
activeEditorPane
.
getControl
()
as
INotebookEditor
;
this
.
_localStore
.
add
(
editor
.
onDidChangeKernel
(()
=>
{
this
.
updateKernelInfo
(
editor
.
activeKernel
);
}));
this
.
updateKernelInfo
(
editor
.
activeKernel
);
}
private
updateKernelInfo
(
kernelInfo
:
INotebookKernelInfo
|
undefined
)
{
if
(
!
kernelInfo
)
{
this
.
kernelInfoElement
.
clear
();
return
;
}
const
props
:
IStatusbarEntry
=
{
text
:
kernelInfo
.
label
,
ariaLabel
:
kernelInfo
.
label
,
tooltip
:
nls
.
localize
(
'
selectKernel
'
,
"
Select Notebook Kernel
"
),
command
:
'
notebook.selectKernel
'
};
this
.
updateElement
(
this
.
kernelInfoElement
,
props
,
'
status.notebook.kernel
'
,
nls
.
localize
(
'
selectKernel
'
,
"
Select Notebook Kernel
"
),
StatusbarAlignment
.
RIGHT
,
50
);
}
private
updateElement
(
element
:
MutableDisposable
<
IStatusbarEntryAccessor
>
,
props
:
IStatusbarEntry
,
id
:
string
,
name
:
string
,
alignment
:
StatusbarAlignment
,
priority
:
number
)
{
if
(
!
element
.
value
)
{
element
.
value
=
this
.
statusbarService
.
addEntry
(
props
,
id
,
name
,
alignment
,
priority
);
}
else
{
element
.
value
.
update
(
props
);
}
}
}
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
).
registerWorkbenchContribution
(
NotebookEditorStatus
,
LifecyclePhase
.
Eventually
);
registerAction2
(
class
extends
Action2
{
constructor
()
{
super
({
id
:
'
notebook.selectKernel
'
,
category
:
NOTEBOOK_ACTIONS_CATEGORY
,
title
:
nls
.
localize
(
'
notebookActions.selectKernel
'
,
"
Select Notebook Kernel
"
),
precondition
:
ContextKeyExpr
.
and
(
NOTEBOOK_IS_ACTIVE_EDITOR
,
NOTEBOOK_EDITOR_FOCUSED
),
f1
:
true
});
}
async
run
(
accessor
:
ServicesAccessor
,
context
?:
INotebookCellActionContext
):
Promise
<
void
>
{
const
editorService
=
accessor
.
get
<
IEditorService
>
(
IEditorService
);
const
notebookService
=
accessor
.
get
<
INotebookService
>
(
INotebookService
);
const
quickInputService
=
accessor
.
get
<
IQuickInputService
>
(
IQuickInputService
);
const
activeEditorPane
=
editorService
.
activeEditorPane
as
any
|
undefined
;
if
(
!
activeEditorPane
?.
isNotebookEditor
)
{
return
;
}
const
editor
=
activeEditorPane
.
getControl
()
as
INotebookEditor
;
const
activeKernel
=
editor
.
activeKernel
;
const
availableKernels
=
notebookService
.
getContributedNotebookKernels
(
editor
.
viewModel
!
.
viewType
,
editor
.
viewModel
!
.
uri
);
const
picks
:
QuickPickInput
<
IQuickPickItem
&
{
run
():
void
;
}
>
[]
=
availableKernels
.
map
((
a
)
=>
{
return
{
id
:
a
.
id
,
label
:
a
.
label
,
picked
:
a
.
id
===
activeKernel
?.
id
,
description
:
a
.
extension
.
value
+
(
a
.
id
===
activeKernel
?.
id
?
nls
.
localize
(
'
currentActiveKernel
'
,
"
(Currently Active)
"
)
:
''
),
run
:
()
=>
{
editor
.
activeKernel
=
a
;
}
};
});
const
action
=
await
quickInputService
.
pick
(
picks
,
{
placeHolder
:
nls
.
localize
(
'
pickAction
'
,
"
Select Action
"
),
matchOnDetail
:
true
});
return
action
?.
run
();
}
});
src/vs/workbench/contrib/notebook/browser/notebook.contribution.ts
浏览文件 @
e3c3ea27
...
...
@@ -45,6 +45,7 @@ import 'vs/workbench/contrib/notebook/browser/contrib/fold/folding';
import
'
vs/workbench/contrib/notebook/browser/contrib/format/formatting
'
;
import
'
vs/workbench/contrib/notebook/browser/contrib/toc/tocProvider
'
;
import
'
vs/workbench/contrib/notebook/browser/contrib/marker/markerProvider
'
;
import
'
vs/workbench/contrib/notebook/browser/contrib/status/editorStatus
'
;
// Output renderers registration
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
e3c3ea27
...
...
@@ -23,7 +23,7 @@ import { OutputRenderer } from 'vs/workbench/contrib/notebook/browser/view/outpu
import
{
CellLanguageStatusBarItem
,
TimerRenderer
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer
'
;
import
{
CellViewModel
,
IModelDecorationsChangeAccessor
,
NotebookViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
CellKind
,
IOutput
,
IRenderOutput
,
NotebookCellMetadata
,
NotebookDocumentMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
IOutput
,
IRenderOutput
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
INotebookKernelInfo
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
Webview
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
ICompositeCodeEditor
}
from
'
vs/editor/common/editorCommon
'
;
...
...
@@ -150,6 +150,8 @@ export interface INotebookEditor extends ICompositeCodeEditor {
*/
readonly
onDidChangeModel
:
Event
<
void
>
;
isNotebookEditor
:
boolean
;
activeKernel
:
INotebookKernelInfo
|
undefined
;
readonly
onDidChangeKernel
:
Event
<
void
>
;
getDomNode
():
HTMLElement
;
getInnerWebview
():
Webview
|
undefined
;
...
...
src/vs/workbench/contrib/notebook/common/notebookCommon.ts
浏览文件 @
e3c3ea27
...
...
@@ -105,6 +105,7 @@ export interface INotebookRendererInfo {
export
interface
INotebookKernelInfo
{
id
:
string
;
label
:
string
,
selectors
:
(
string
|
glob
.
IRelativePattern
)[],
extension
:
ExtensionIdentifier
;
extensionLocation
:
URI
,
...
...
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
浏览文件 @
e3c3ea27
...
...
@@ -19,7 +19,7 @@ import { NotebookEventDispatcher } from 'vs/workbench/contrib/notebook/browser/v
import
{
CellViewModel
,
IModelDecorationsChangeAccessor
,
NotebookViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
import
{
CellKind
,
CellUri
,
INotebookEditorModel
,
IOutput
,
NotebookCellMetadata
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
CellUri
,
INotebookEditorModel
,
IOutput
,
NotebookCellMetadata
,
INotebookKernelInfo
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
Webview
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
ICompositeCodeEditor
,
IEditor
}
from
'
vs/editor/common/editorCommon
'
;
export
class
TestCell
extends
NotebookCellTextModel
{
...
...
@@ -43,6 +43,8 @@ export class TestNotebookEditor implements INotebookEditor {
constructor
(
)
{
}
activeKernel
:
INotebookKernelInfo
|
undefined
;
onDidChangeKernel
:
Event
<
void
>
=
new
Emitter
<
void
>
().
event
;
onDidChangeActiveEditor
:
Event
<
ICompositeCodeEditor
>
=
new
Emitter
<
ICompositeCodeEditor
>
().
event
;
activeCodeEditor
:
IEditor
|
undefined
;
getDomNode
():
HTMLElement
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录