Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
掘金者说
vscode
提交
ed1ecfd5
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,发现更多精彩内容 >>
提交
ed1ecfd5
编写于
7月 16, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
kernel picker status bar item.
上级
be44e409
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
74 addition
and
17 deletion
+74
-17
src/vs/workbench/contrib/notebook/browser/contrib/status/editorStatus.ts
...h/contrib/notebook/browser/contrib/status/editorStatus.ts
+61
-12
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+3
-2
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
...orkbench/contrib/notebook/browser/notebookEditorWidget.ts
+7
-2
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
...workbench/contrib/notebook/browser/notebookServiceImpl.ts
+1
-1
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
+2
-0
未找到文件。
src/vs/workbench/contrib/notebook/browser/contrib/status/editorStatus.ts
浏览文件 @
ed1ecfd5
...
...
@@ -4,15 +4,20 @@
*--------------------------------------------------------------------------------------------*/
import
*
as
nls
from
'
vs/nls
'
;
import
{
Action2
,
MenuId
,
registerAction2
}
from
'
vs/platform/actions/common/actions
'
;
import
{
Registry
}
from
'
vs/platform/registry/common/platform
'
;
import
{
Action2
,
registerAction2
}
from
'
vs/platform/actions/common/actions
'
;
import
{
ServicesAccessor
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
IQuickInputService
,
IQuickPickItem
,
QuickPickInput
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
INotebookCellActionContext
,
NOTEBOOK_ACTIONS_CATEGORY
}
from
'
vs/workbench/contrib/notebook/browser/contrib/coreActions
'
;
import
{
INotebookEditor
,
NOTEBOOK_
HAS_MULTIPLE_KERNELS
,
NOTEBOOK_
IS_ACTIVE_EDITOR
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
INotebookCellActionContext
,
NOTEBOOK_ACTIONS_CATEGORY
,
getActiveNotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/contrib/coreActions
'
;
import
{
INotebookEditor
,
NOTEBOOK_IS_ACTIVE_EDITOR
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
import
{
IEditorService
}
from
'
vs/workbench/services/editor/common/editorService
'
;
import
{
CancellationTokenSource
}
from
'
vs/base/common/cancellation
'
;
import
{
INotebookKernelInfoDto2
,
INotebookKernelInfo2
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
INotebookKernelInfo2
,
INotebookKernelInfo
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
Extensions
as
WorkbenchExtensions
,
IWorkbenchContributionsRegistry
,
IWorkbenchContribution
}
from
'
vs/workbench/common/contributions
'
;
import
{
LifecyclePhase
}
from
'
vs/platform/lifecycle/common/lifecycle
'
;
import
{
Disposable
,
DisposableStore
,
MutableDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
IStatusbarEntryAccessor
,
IStatusbarService
,
StatusbarAlignment
}
from
'
vs/workbench/services/statusbar/common/statusbar
'
;
registerAction2
(
class
extends
Action2
{
...
...
@@ -23,12 +28,6 @@ registerAction2(class extends Action2 {
title
:
{
value
:
nls
.
localize
(
'
notebookActions.selectKernel
'
,
"
Select Notebook Kernel
"
),
original
:
'
Select Notebook Kernel
'
},
precondition
:
NOTEBOOK_IS_ACTIVE_EDITOR
,
icon
:
{
id
:
'
codicon/server-environment
'
},
menu
:
{
id
:
MenuId
.
EditorTitle
,
when
:
NOTEBOOK_HAS_MULTIPLE_KERNELS
,
group
:
'
navigation
'
,
order
:
-
2
,
},
f1
:
true
});
}
...
...
@@ -54,8 +53,8 @@ registerAction2(class extends Action2 {
label
:
a
.
label
,
picked
:
a
.
id
===
activeKernel
?.
id
,
description
:
(
a
as
INotebookKernelInfo
Dto
2
).
description
?
(
a
as
INotebookKernelInfo
Dto
2
).
description
(
a
as
INotebookKernelInfo2
).
description
?
(
a
as
INotebookKernelInfo2
).
description
:
a
.
extension
.
value
+
(
a
.
id
===
activeKernel
?.
id
?
nls
.
localize
(
'
currentActiveKernel
'
,
"
(Currently Active)
"
)
:
''
),
...
...
@@ -89,3 +88,53 @@ registerAction2(class extends Action2 {
}
});
export
class
KernelStatus
extends
Disposable
implements
IWorkbenchContribution
{
private
_editorDisposable
=
new
DisposableStore
();
private
readonly
kernelInfoElement
=
this
.
_register
(
new
MutableDisposable
<
IStatusbarEntryAccessor
>
());
constructor
(
@
IEditorService
private
readonly
_editorService
:
IEditorService
,
@
INotebookService
private
readonly
_notebookService
:
INotebookService
,
@
IStatusbarService
private
readonly
_statusbarService
:
IStatusbarService
,
)
{
super
();
this
.
registerListeners
();
}
registerListeners
()
{
this
.
_register
(
this
.
_editorService
.
onDidActiveEditorChange
(()
=>
this
.
updateStatusbar
()));
this
.
_register
(
this
.
_notebookService
.
onDidChangeActiveEditor
(()
=>
this
.
updateStatusbar
()));
this
.
_register
(
this
.
_notebookService
.
onDidChangeKernels
(()
=>
this
.
updateStatusbar
()));
}
updateStatusbar
()
{
this
.
_editorDisposable
.
clear
();
const
activeEditor
=
getActiveNotebookEditor
(
this
.
_editorService
);
if
(
activeEditor
&&
activeEditor
.
multipleKernelsAvailable
)
{
this
.
showKernelStatus
(
activeEditor
.
activeKernel
);
this
.
_editorDisposable
.
add
(
activeEditor
.
onDidChangeKernel
(()
=>
{
if
(
activeEditor
.
multipleKernelsAvailable
)
{
this
.
showKernelStatus
(
activeEditor
.
activeKernel
);
}
else
{
this
.
kernelInfoElement
.
clear
();
}
}));
}
else
{
this
.
kernelInfoElement
.
clear
();
}
}
showKernelStatus
(
kernel
:
INotebookKernelInfo
|
INotebookKernelInfo2
|
undefined
)
{
this
.
kernelInfoElement
.
value
=
this
.
_statusbarService
.
addEntry
({
text
:
kernel
?
kernel
.
label
:
'
Choose Kernel
'
,
ariaLabel
:
kernel
?
kernel
.
label
:
'
Choose Kernel
'
,
tooltip
:
nls
.
localize
(
'
chooseActiveKernel
'
,
"
Choose kernel for current notebook
"
),
command
:
'
notebook.selectKernel
'
,
},
'
notebook.selectKernel
'
,
nls
.
localize
(
'
notebook.selectKernel
'
,
"
Choose kernel for current notebook
"
),
StatusbarAlignment
.
RIGHT
,
100
);
}
}
Registry
.
as
<
IWorkbenchContributionsRegistry
>
(
WorkbenchExtensions
.
Workbench
).
registerWorkbenchContribution
(
KernelStatus
,
LifecyclePhase
.
Ready
);
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
ed1ecfd5
...
...
@@ -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
,
IProcessedOutput
,
IRenderOutput
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
INotebookKernelInfo
,
IEditor
,
INotebookKernelInfoDto2
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
CellKind
,
IProcessedOutput
,
IRenderOutput
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
INotebookKernelInfo
,
IEditor
,
INotebookKernelInfoDto2
,
INotebookKernelInfo2
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
Webview
}
from
'
vs/workbench/contrib/webview/browser/webview
'
;
import
{
NotebookTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookTextModel
'
;
...
...
@@ -171,7 +171,8 @@ export interface INotebookEditor extends IEditor {
readonly
onDidChangeModel
:
Event
<
NotebookTextModel
|
undefined
>
;
readonly
onDidFocusEditorWidget
:
Event
<
void
>
;
isNotebookEditor
:
boolean
;
activeKernel
:
INotebookKernelInfo
|
INotebookKernelInfoDto2
|
undefined
;
activeKernel
:
INotebookKernelInfo
|
INotebookKernelInfo2
|
undefined
;
multipleKernelsAvailable
:
boolean
;
readonly
onDidChangeKernel
:
Event
<
void
>
;
isDisposed
:
boolean
;
...
...
src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
浏览文件 @
ed1ecfd5
...
...
@@ -132,7 +132,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
return
this
.
_notebookViewModel
?.
notebookDocument
;
}
private
_activeKernel
:
INotebookKernelInfo
|
INotebookKernelInfo
Dto
2
|
undefined
=
undefined
;
private
_activeKernel
:
INotebookKernelInfo
|
INotebookKernelInfo2
|
undefined
=
undefined
;
private
readonly
_onDidChangeKernel
=
this
.
_register
(
new
Emitter
<
void
>
());
readonly
onDidChangeKernel
:
Event
<
void
>
=
this
.
_onDidChangeKernel
.
event
;
...
...
@@ -140,7 +140,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
return
this
.
_activeKernel
;
}
set
activeKernel
(
kernel
:
INotebookKernelInfo
|
INotebookKernelInfo
Dto
2
|
undefined
)
{
set
activeKernel
(
kernel
:
INotebookKernelInfo
|
INotebookKernelInfo2
|
undefined
)
{
if
(
this
.
_isDisposed
)
{
return
;
}
...
...
@@ -149,6 +149,8 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
this
.
_onDidChangeKernel
.
fire
();
}
multipleKernelsAvailable
:
boolean
=
false
;
private
readonly
_onDidChangeActiveEditor
=
this
.
_register
(
new
Emitter
<
this
>
());
readonly
onDidChangeActiveEditor
:
Event
<
this
>
=
this
.
_onDidChangeActiveEditor
.
event
;
...
...
@@ -560,10 +562,13 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditor
if
(
provider
.
kernel
&&
(
availableKernels
.
length
+
availableKernels2
.
length
)
>
0
)
{
this
.
_notebookHasMultipleKernels
!
.
set
(
true
);
this
.
multipleKernelsAvailable
=
true
;
}
else
if
((
availableKernels
.
length
+
availableKernels2
.
length
)
>
1
)
{
this
.
_notebookHasMultipleKernels
!
.
set
(
true
);
this
.
multipleKernelsAvailable
=
true
;
}
else
{
this
.
_notebookHasMultipleKernels
!
.
set
(
false
);
this
.
multipleKernelsAvailable
=
false
;
}
if
(
provider
&&
provider
.
kernel
)
{
...
...
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
浏览文件 @
ed1ecfd5
...
...
@@ -329,7 +329,7 @@ export class NotebookService extends Disposable implements INotebookService, ICu
const
tokenSource
=
new
CancellationTokenSource
();
return
provider
.
resolveKernel
(
editorId
,
uri
,
dto
.
id
,
tokenSource
.
token
);
},
executeNotebook
:
async
(
uri
:
URI
,
handle
:
number
|
undefined
,
token
:
CancellationToken
)
=>
{
executeNotebook
Cell
:
async
(
uri
:
URI
,
handle
:
number
|
undefined
,
token
:
CancellationToken
)
=>
{
return
provider
.
executeNotebook
(
uri
,
dto
.
id
,
handle
,
token
);
}
};
...
...
src/vs/workbench/contrib/notebook/test/testNotebookEditor.ts
浏览文件 @
ed1ecfd5
...
...
@@ -62,6 +62,8 @@ export class TestNotebookEditor implements INotebookEditor {
constructor
(
)
{
}
multipleKernelsAvailable
:
boolean
=
false
;
uri
?:
URI
|
undefined
;
textModel
?:
NotebookTextModel
|
undefined
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录