Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
xxadev
vscode
提交
e66547a1
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,体验更适合开发者的 AI 搜索 >>
提交
e66547a1
编写于
11月 23, 2020
作者:
R
rebornix
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
ensure the editor has enough top padding when there is decoration ::after: { top }
上级
0baf6bb9
变更
12
隐藏空白更改
内联
并排
Showing
12 changed file
with
119 addition
and
27 deletion
+119
-27
src/vs/editor/browser/services/abstractCodeEditorService.ts
src/vs/editor/browser/services/abstractCodeEditorService.ts
+3
-0
src/vs/editor/browser/services/codeEditorService.ts
src/vs/editor/browser/services/codeEditorService.ts
+2
-0
src/vs/editor/browser/services/codeEditorServiceImpl.ts
src/vs/editor/browser/services/codeEditorServiceImpl.ts
+28
-2
src/vs/workbench/contrib/notebook/browser/constants.ts
src/vs/workbench/contrib/notebook/browser/constants.ts
+1
-1
src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts
...workbench/contrib/notebook/browser/diff/cellComponents.ts
+5
-4
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
+15
-1
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
...workbench/contrib/notebook/browser/notebookServiceImpl.ts
+43
-2
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
...h/contrib/notebook/browser/view/renderers/cellRenderer.ts
+9
-4
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
...bench/contrib/notebook/browser/view/renderers/codeCell.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
...h/contrib/notebook/browser/view/renderers/markdownCell.ts
+3
-3
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
...h/contrib/notebook/browser/viewModel/baseCellViewModel.ts
+4
-4
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
...h/contrib/notebook/browser/viewModel/codeCellViewModel.ts
+3
-3
未找到文件。
src/vs/editor/browser/services/abstractCodeEditorService.ts
浏览文件 @
e66547a1
...
...
@@ -31,6 +31,8 @@ export abstract class AbstractCodeEditorService extends Disposable implements IC
private
readonly
_onDidChangeTransientModelProperty
:
Emitter
<
ITextModel
>
=
this
.
_register
(
new
Emitter
<
ITextModel
>
());
public
readonly
onDidChangeTransientModelProperty
:
Event
<
ITextModel
>
=
this
.
_onDidChangeTransientModelProperty
.
event
;
protected
readonly
_onDecorationTypeRegistered
:
Emitter
<
string
>
=
this
.
_register
(
new
Emitter
<
string
>
());
public
onDecorationTypeRegistered
:
Event
<
string
>
=
this
.
_onDecorationTypeRegistered
.
event
;
private
readonly
_codeEditors
:
{
[
editorId
:
string
]:
ICodeEditor
;
};
private
readonly
_diffEditors
:
{
[
editorId
:
string
]:
IDiffEditor
;
};
...
...
@@ -93,6 +95,7 @@ export abstract class AbstractCodeEditorService extends Disposable implements IC
abstract
registerDecorationType
(
key
:
string
,
options
:
IDecorationRenderOptions
,
parentTypeKey
?:
string
,
editor
?:
ICodeEditor
):
void
;
abstract
removeDecorationType
(
key
:
string
):
void
;
abstract
resolveDecorationOptions
(
decorationTypeKey
:
string
|
undefined
,
writable
:
boolean
):
IModelDecorationOptions
;
abstract
resolveDecorationCSSRules
(
decorationTypeKey
:
string
):
CSSRuleList
|
null
;
private
readonly
_transientWatchers
:
{
[
uri
:
string
]:
ModelTransientSettingWatcher
;
}
=
{};
private
readonly
_modelProperties
=
new
Map
<
string
,
Map
<
string
,
any
>>
();
...
...
src/vs/editor/browser/services/codeEditorService.ts
浏览文件 @
e66547a1
...
...
@@ -23,6 +23,7 @@ export interface ICodeEditorService {
readonly
onDiffEditorRemove
:
Event
<
IDiffEditor
>
;
readonly
onDidChangeTransientModelProperty
:
Event
<
ITextModel
>
;
readonly
onDecorationTypeRegistered
:
Event
<
string
>
;
addCodeEditor
(
editor
:
ICodeEditor
):
void
;
...
...
@@ -41,6 +42,7 @@ export interface ICodeEditorService {
registerDecorationType
(
key
:
string
,
options
:
IDecorationRenderOptions
,
parentTypeKey
?:
string
,
editor
?:
ICodeEditor
):
void
;
removeDecorationType
(
key
:
string
):
void
;
resolveDecorationOptions
(
typeKey
:
string
,
writable
:
boolean
):
IModelDecorationOptions
;
resolveDecorationCSSRules
(
decorationTypeKey
:
string
):
CSSRuleList
|
null
;
setModelProperty
(
resource
:
URI
,
key
:
string
,
value
:
any
):
void
;
getModelProperty
(
resource
:
URI
,
key
:
string
):
any
;
...
...
src/vs/editor/browser/services/codeEditorServiceImpl.ts
浏览文件 @
e66547a1
...
...
@@ -21,6 +21,10 @@ export class RefCountedStyleSheet {
private
readonly
_styleSheet
:
HTMLStyleElement
;
private
_refCount
:
number
;
public
get
sheet
()
{
return
this
.
_styleSheet
.
sheet
as
CSSStyleSheet
;
}
constructor
(
parent
:
CodeEditorServiceImpl
,
editorId
:
string
,
styleSheet
:
HTMLStyleElement
)
{
this
.
_parent
=
parent
;
this
.
_editorId
=
editorId
;
...
...
@@ -53,6 +57,10 @@ export class RefCountedStyleSheet {
export
class
GlobalStyleSheet
{
private
readonly
_styleSheet
:
HTMLStyleElement
;
public
get
sheet
()
{
return
this
.
_styleSheet
.
sheet
as
CSSStyleSheet
;
}
constructor
(
styleSheet
:
HTMLStyleElement
)
{
this
.
_styleSheet
=
styleSheet
;
}
...
...
@@ -129,6 +137,7 @@ export abstract class CodeEditorServiceImpl extends AbstractCodeEditorService {
provider
=
new
DecorationSubTypeOptionsProvider
(
this
.
_themeService
,
styleSheet
,
providerArgs
);
}
this
.
_decorationOptionProviders
.
set
(
key
,
provider
);
this
.
_onDecorationTypeRegistered
.
fire
(
key
);
}
provider
.
refCount
++
;
}
...
...
@@ -153,6 +162,14 @@ export abstract class CodeEditorServiceImpl extends AbstractCodeEditorService {
return
provider
.
getOptions
(
this
,
writable
);
}
public
resolveDecorationCSSRules
(
decorationTypeKey
:
string
)
{
const
provider
=
this
.
_decorationOptionProviders
.
get
(
decorationTypeKey
);
if
(
!
provider
)
{
return
null
;
}
return
provider
.
resolveDecorationCSSRules
();
}
abstract
getActiveCodeEditor
():
ICodeEditor
|
null
;
abstract
openCodeEditor
(
input
:
IResourceEditorInput
,
source
:
ICodeEditor
|
null
,
sideBySide
?:
boolean
):
Promise
<
ICodeEditor
|
null
>
;
}
...
...
@@ -160,9 +177,10 @@ export abstract class CodeEditorServiceImpl extends AbstractCodeEditorService {
interface
IModelDecorationOptionsProvider
extends
IDisposable
{
refCount
:
number
;
getOptions
(
codeEditorService
:
AbstractCodeEditorService
,
writable
:
boolean
):
IModelDecorationOptions
;
resolveDecorationCSSRules
():
CSSRuleList
;
}
class
DecorationSubTypeOptionsProvider
implements
IModelDecorationOptionsProvider
{
export
class
DecorationSubTypeOptionsProvider
implements
IModelDecorationOptionsProvider
{
private
readonly
_styleSheet
:
GlobalStyleSheet
|
RefCountedStyleSheet
;
public
refCount
:
number
;
...
...
@@ -192,6 +210,10 @@ class DecorationSubTypeOptionsProvider implements IModelDecorationOptionsProvide
return
options
;
}
public
resolveDecorationCSSRules
():
CSSRuleList
{
return
this
.
_styleSheet
.
sheet
.
cssRules
;
}
public
dispose
():
void
{
if
(
this
.
_beforeContentRules
)
{
this
.
_beforeContentRules
.
dispose
();
...
...
@@ -213,7 +235,7 @@ interface ProviderArguments {
}
class
DecorationTypeOptionsProvider
implements
IModelDecorationOptionsProvider
{
export
class
DecorationTypeOptionsProvider
implements
IModelDecorationOptionsProvider
{
private
readonly
_disposables
=
new
DisposableStore
();
private
readonly
_styleSheet
:
GlobalStyleSheet
|
RefCountedStyleSheet
;
...
...
@@ -295,6 +317,10 @@ class DecorationTypeOptionsProvider implements IModelDecorationOptionsProvider {
};
}
public
resolveDecorationCSSRules
():
CSSRuleList
{
return
this
.
_styleSheet
.
sheet
.
rules
;
}
public
dispose
():
void
{
this
.
_disposables
.
dispose
();
this
.
_styleSheet
.
unref
();
...
...
src/vs/workbench/contrib/notebook/browser/constants.ts
浏览文件 @
e66547a1
...
...
@@ -22,7 +22,7 @@ export const CELL_TOP_MARGIN = 6;
export
const
CELL_BOTTOM_MARGIN
=
6
;
// Top and bottom padding inside the monaco editor in a cell, which are included in `cell.editorHeight`
export
const
EDITOR_TOP_PADDING
=
12
;
//
export const EDITOR_TOP_PADDING = 12;
export
const
EDITOR_BOTTOM_PADDING
=
4
;
export
const
EDITOR_BOTTOM_PADDING_WITHOUT_STATUSBAR
=
12
;
...
...
src/vs/workbench/contrib/notebook/browser/diff/cellComponents.ts
浏览文件 @
e66547a1
...
...
@@ -9,7 +9,7 @@ import { IDiffEditorOptions, IEditorOptions } from 'vs/editor/common/config/edit
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
CellDiffViewModel
,
PropertyFoldingState
}
from
'
vs/workbench/contrib/notebook/browser/diff/celllDiffViewModel
'
;
import
{
CellDiffRenderTemplate
,
CellDiffViewModelLayoutChangeEvent
,
DIFF_CELL_MARGIN
,
INotebookTextDiffEditor
}
from
'
vs/workbench/contrib/notebook/browser/diff/common
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
EDITOR_BOTTOM_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CodeEditorWidget
}
from
'
vs/editor/browser/widget/codeEditorWidget
'
;
import
{
DiffEditorWidget
}
from
'
vs/editor/browser/widget/diffEditorWidget
'
;
import
{
renderCodicons
}
from
'
vs/base/browser/codicons
'
;
...
...
@@ -28,6 +28,7 @@ import { IAction } from 'vs/base/common/actions';
import
{
createAndFillInActionBarActions
}
from
'
vs/platform/actions/browser/menuEntryActionViewItem
'
;
import
{
IContextKeyService
}
from
'
vs/platform/contextkey/common/contextkey
'
;
import
{
CodiconActionViewItem
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellActionView
'
;
import
{
getEditorTopPadding
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
const
fixedEditorOptions
:
IEditorOptions
=
{
padding
:
{
...
...
@@ -758,7 +759,7 @@ export class DeletedCell extends AbstractCellRenderer {
const
originalCell
=
this
.
cell
.
original
!
;
const
lineCount
=
originalCell
.
textBuffer
.
getLineCount
();
const
lineHeight
=
this
.
notebookEditor
.
getLayoutInfo
().
fontInfo
.
lineHeight
||
17
;
const
editorHeight
=
lineCount
*
lineHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
;
const
editorHeight
=
lineCount
*
lineHeight
+
getEditorTopPadding
()
+
EDITOR_BOTTOM_PADDING
;
const
editorContainer
=
DOM
.
append
(
sourceContainer
,
DOM
.
$
(
'
.editor-container
'
));
...
...
@@ -858,7 +859,7 @@ export class InsertCell extends AbstractCellRenderer {
const
modifiedCell
=
this
.
cell
.
modified
!
;
const
lineCount
=
modifiedCell
.
textBuffer
.
getLineCount
();
const
lineHeight
=
this
.
notebookEditor
.
getLayoutInfo
().
fontInfo
.
lineHeight
||
17
;
const
editorHeight
=
lineCount
*
lineHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
;
const
editorHeight
=
lineCount
*
lineHeight
+
getEditorTopPadding
()
+
EDITOR_BOTTOM_PADDING
;
const
editorContainer
=
DOM
.
append
(
sourceContainer
,
DOM
.
$
(
'
.editor-container
'
));
this
.
_editor
=
this
.
instantiationService
.
createInstance
(
CodeEditorWidget
,
editorContainer
,
{
...
...
@@ -962,7 +963,7 @@ export class ModifiedCell extends AbstractCellRenderer {
const
modifiedCell
=
this
.
cell
.
modified
!
;
const
lineCount
=
modifiedCell
.
textBuffer
.
getLineCount
();
const
lineHeight
=
this
.
notebookEditor
.
getLayoutInfo
().
fontInfo
.
lineHeight
||
17
;
const
editorHeight
=
lineCount
*
lineHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
;
const
editorHeight
=
lineCount
*
lineHeight
+
getEditorTopPadding
()
+
EDITOR_BOTTOM_PADDING
;
this
.
_editorContainer
=
DOM
.
append
(
sourceContainer
,
DOM
.
$
(
'
.editor-container
'
));
this
.
_editor
=
this
.
instantiationService
.
createInstance
(
DiffEditorWidget
,
this
.
_editorContainer
,
{
...
...
src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
浏览文件 @
e66547a1
...
...
@@ -8,7 +8,7 @@ import { IListContextMenuEvent, IListEvent, IListMouseEvent } from 'vs/base/brow
import
{
IListOptions
,
IListStyles
}
from
'
vs/base/browser/ui/list/listWidget
'
;
import
{
ProgressBar
}
from
'
vs/base/browser/ui/progressbar/progressbar
'
;
import
{
ToolBar
}
from
'
vs/base/browser/ui/toolbar/toolbar
'
;
import
{
Event
}
from
'
vs/base/common/event
'
;
import
{
E
mitter
,
E
vent
}
from
'
vs/base/common/event
'
;
import
{
DisposableStore
,
IDisposable
}
from
'
vs/base/common/lifecycle
'
;
import
{
ScrollEvent
}
from
'
vs/base/common/scrollable
'
;
import
{
URI
}
from
'
vs/base/common/uri
'
;
...
...
@@ -720,3 +720,17 @@ export function getActiveNotebookEditor(editorService: IEditorService): INoteboo
const
activeEditorPane
=
editorService
.
activeEditorPane
as
unknown
as
{
isNotebookEditor
?:
boolean
}
|
undefined
;
return
activeEditorPane
?.
isNotebookEditor
?
(
editorService
.
activeEditorPane
?.
getControl
()
as
INotebookEditor
)
:
undefined
;
}
let
EDITOR_TOP_PADDING
=
12
;
const
editorTopPaddingChangeEmitter
=
new
Emitter
<
void
>
();
export
const
EditorTopPaddingChangeEvent
=
editorTopPaddingChangeEmitter
.
event
;
export
function
updateEditorTopPadding
(
top
:
number
)
{
EDITOR_TOP_PADDING
=
top
;
editorTopPaddingChangeEmitter
.
fire
();
}
export
function
getEditorTopPadding
()
{
return
EDITOR_TOP_PADDING
;
}
src/vs/workbench/contrib/notebook/browser/notebookServiceImpl.ts
浏览文件 @
e66547a1
...
...
@@ -3,6 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import
{
getZoomLevel
}
from
'
vs/base/browser/browser
'
;
import
{
flatten
}
from
'
vs/base/common/arrays
'
;
import
{
CancellationToken
}
from
'
vs/base/common/cancellation
'
;
import
{
Emitter
,
Event
}
from
'
vs/base/common/event
'
;
...
...
@@ -13,6 +14,9 @@ import { Schemas } from 'vs/base/common/network';
import
{
URI
}
from
'
vs/base/common/uri
'
;
import
*
as
UUID
from
'
vs/base/common/uuid
'
;
import
{
RedoCommand
,
UndoCommand
}
from
'
vs/editor/browser/editorExtensions
'
;
import
{
ICodeEditorService
}
from
'
vs/editor/browser/services/codeEditorService
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
BareFontInfo
}
from
'
vs/editor/common/config/fontInfo
'
;
import
{
CopyAction
,
CutAction
,
PasteAction
}
from
'
vs/editor/contrib/clipboard/clipboard
'
;
import
*
as
nls
from
'
vs/nls
'
;
import
{
IAccessibilityService
}
from
'
vs/platform/accessibility/common/accessibility
'
;
...
...
@@ -23,7 +27,7 @@ import { IStorageService, StorageScope, StorageTarget } from 'vs/platform/storag
import
{
NotebookExtensionDescription
}
from
'
vs/workbench/api/common/extHost.protocol
'
;
import
{
Memento
}
from
'
vs/workbench/common/memento
'
;
import
{
INotebookEditorContribution
,
notebookProviderExtensionPoint
,
notebookRendererExtensionPoint
}
from
'
vs/workbench/contrib/notebook/browser/extensionPoint
'
;
import
{
CellEditState
,
getActiveNotebookEditor
,
INotebookEditor
,
NotebookEditorOptions
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellEditState
,
getActiveNotebookEditor
,
INotebookEditor
,
NotebookEditorOptions
,
updateEditorTopPadding
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
NotebookKernelProviderAssociationRegistry
,
NotebookViewTypesExtensionRegistry
,
updateNotebookKernelProvideAssociationSchema
}
from
'
vs/workbench/contrib/notebook/browser/notebookKernelAssociation
'
;
import
{
CellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/notebookViewModel
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
...
...
@@ -276,7 +280,9 @@ export class NotebookService extends Disposable implements INotebookService, ICu
@
IConfigurationService
private
readonly
_configurationService
:
IConfigurationService
,
@
IAccessibilityService
private
readonly
_accessibilityService
:
IAccessibilityService
,
@
IStorageService
private
readonly
_storageService
:
IStorageService
,
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
@
IInstantiationService
private
readonly
_instantiationService
:
IInstantiationService
,
@
ICodeEditorService
private
readonly
_codeEditorService
:
ICodeEditorService
,
@
IConfigurationService
private
readonly
configurationService
:
IConfigurationService
)
{
super
();
...
...
@@ -336,6 +342,41 @@ export class NotebookService extends Disposable implements INotebookService, ICu
updateOrder
();
}));
let
decorationTriggeredAdjustment
=
false
;
let
decorationCheckSet
=
new
Set
<
string
>
();
this
.
_register
(
this
.
_codeEditorService
.
onDecorationTypeRegistered
(
e
=>
{
if
(
decorationTriggeredAdjustment
)
{
return
;
}
if
(
decorationCheckSet
.
has
(
e
))
{
return
;
}
const
options
=
this
.
_codeEditorService
.
resolveDecorationOptions
(
e
,
true
);
if
(
options
.
afterContentClassName
||
options
.
beforeContentClassName
)
{
const
cssRules
=
this
.
_codeEditorService
.
resolveDecorationCSSRules
(
e
);
if
(
cssRules
!==
null
)
{
for
(
let
i
=
0
;
i
<
cssRules
.
length
;
i
++
)
{
// The following ways to index into the list are equivalent
if
(
((
cssRules
[
i
]
as
CSSStyleRule
).
selectorText
.
endsWith
(
'
::after
'
)
||
(
cssRules
[
i
]
as
CSSStyleRule
).
selectorText
.
endsWith
(
'
::after
'
))
&&
(
cssRules
[
i
]
as
CSSStyleRule
).
cssText
.
indexOf
(
'
top:
'
)
>
-
1
)
{
// there is a `::before` or `::after` text decoration whose position is above or below current line
// we at least make sure that the editor top padding is at least one line
const
editorOptions
=
this
.
configurationService
.
getValue
<
IEditorOptions
>
(
'
editor
'
);
updateEditorTopPadding
(
BareFontInfo
.
createFromRawSettings
(
editorOptions
,
getZoomLevel
()).
lineHeight
+
2
);
decorationTriggeredAdjustment
=
true
;
break
;
}
}
}
}
decorationCheckSet
.
add
(
e
);
}));
const
getContext
=
()
=>
{
const
editor
=
getActiveNotebookEditor
(
this
.
_editorService
);
const
activeCell
=
editor
?.
getActiveCell
();
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/cellRenderer.ts
浏览文件 @
e66547a1
...
...
@@ -35,9 +35,9 @@ import { IInstantiationService } from 'vs/platform/instantiation/common/instanti
import
{
ServiceCollection
}
from
'
vs/platform/instantiation/common/serviceCollection
'
;
import
{
IKeybindingService
}
from
'
vs/platform/keybinding/common/keybinding
'
;
import
{
INotificationService
}
from
'
vs/platform/notification/common/notification
'
;
import
{
BOTTOM_CELL_TOOLBAR_GAP
,
CELL_BOTTOM_MARGIN
,
CELL_TOP_MARGIN
,
EDITOR_BOTTOM_PADDING
,
EDITOR_BOTTOM_PADDING_WITHOUT_STATUSBAR
,
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
BOTTOM_CELL_TOOLBAR_GAP
,
CELL_BOTTOM_MARGIN
,
CELL_TOP_MARGIN
,
EDITOR_BOTTOM_PADDING
,
EDITOR_BOTTOM_PADDING_WITHOUT_STATUSBAR
,
EDITOR_TOOLBAR_HEIGHT
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CancelCellAction
,
DeleteCellAction
,
ExecuteCellAction
,
INotebookCellActionContext
}
from
'
vs/workbench/contrib/notebook/browser/contrib/coreActions
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
CodeCellRenderTemplate
,
E
XPAND_CELL_CONTENT_COMMAND_ID
,
ICellViewModel
,
INotebookEditor
,
isCodeCellRenderTemplate
,
MarkdownCellRenderTemplate
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
BaseCellRenderTemplate
,
CellEditState
,
CodeCellRenderTemplate
,
E
ditorTopPaddingChangeEvent
,
EXPAND_CELL_CONTENT_COMMAND_ID
,
getEditorTopPadding
,
ICellViewModel
,
INotebookEditor
,
isCodeCellRenderTemplate
,
MarkdownCellRenderTemplate
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellContextKeyManager
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellContextKeys
'
;
import
{
CellMenus
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellMenus
'
;
import
{
CellEditorStatusBar
}
from
'
vs/workbench/contrib/notebook/browser/view/renderers/cellWidgets
'
;
...
...
@@ -117,10 +117,16 @@ export class CellEditorOptions {
}
});
EditorTopPaddingChangeEvent
(()
=>
{
this
.
_value
=
computeEditorOptions
();
this
.
_onDidChange
.
fire
(
this
.
value
);
});
const
computeEditorOptions
=
()
=>
{
const
showCellStatusBar
=
configurationService
.
getValue
<
boolean
>
(
ShowCellStatusBarKey
);
const
editorPadding
=
{
top
:
EDITOR_TOP_PADDING
,
top
:
getEditorTopPadding
()
,
bottom
:
showCellStatusBar
?
EDITOR_BOTTOM_PADDING
:
EDITOR_BOTTOM_PADDING_WITHOUT_STATUSBAR
};
...
...
@@ -717,7 +723,6 @@ export class CodeCellRenderer extends AbstractCellRenderer implements IListRende
},
{});
disposables
.
add
(
this
.
editorOptions
.
onDidChange
(
newValue
=>
editor
.
updateOptions
(
newValue
)));
const
{
collapsedPart
,
expandButton
}
=
this
.
setupCollapsedPart
(
container
);
const
progressBar
=
new
ProgressBar
(
editorPart
);
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/codeCell.ts
浏览文件 @
e66547a1
...
...
@@ -11,8 +11,8 @@ import { IDimension } from 'vs/editor/common/editorCommon';
import
{
IModeService
}
from
'
vs/editor/common/services/modeService
'
;
import
{
IOpenerService
}
from
'
vs/platform/opener/common/opener
'
;
import
{
IQuickInputService
}
from
'
vs/platform/quickinput/common/quickInput
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellFocusMode
,
CodeCellRenderTemplate
,
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
EDITOR_BOTTOM_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellFocusMode
,
CodeCellRenderTemplate
,
getEditorTopPadding
,
INotebookEditor
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CodeCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel
'
;
import
{
INotebookService
}
from
'
vs/workbench/contrib/notebook/common/notebookService
'
;
import
{
ITextFileService
}
from
'
vs/workbench/services/textfile/common/textfiles
'
;
...
...
@@ -46,7 +46,7 @@ export class CodeCell extends Disposable {
const
lineNum
=
this
.
viewCell
.
lineCount
;
const
lineHeight
=
this
.
viewCell
.
layoutInfo
.
fontInfo
?.
lineHeight
||
17
;
const
editorHeight
=
this
.
viewCell
.
layoutInfo
.
editorHeight
===
0
?
lineNum
*
lineHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
?
lineNum
*
lineHeight
+
getEditorTopPadding
()
+
EDITOR_BOTTOM_PADDING
:
this
.
viewCell
.
layoutInfo
.
editorHeight
;
this
.
layoutEditor
(
...
...
src/vs/workbench/contrib/notebook/browser/view/renderers/markdownCell.ts
浏览文件 @
e66547a1
...
...
@@ -11,8 +11,8 @@ import { Disposable, DisposableStore, IDisposable, toDisposable } from 'vs/base/
import
{
CodeEditorWidget
}
from
'
vs/editor/browser/widget/codeEditorWidget
'
;
import
{
IEditorOptions
}
from
'
vs/editor/common/config/editorOptions
'
;
import
{
IInstantiationService
}
from
'
vs/platform/instantiation/common/instantiation
'
;
import
{
EDITOR_BOTTOM_PADDING
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFocusMode
,
INotebookEditor
,
MarkdownCellRenderTemplate
,
ICellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
EDITOR_BOTTOM_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFocusMode
,
INotebookEditor
,
MarkdownCellRenderTemplate
,
ICellViewModel
,
getEditorTopPadding
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellFoldingState
}
from
'
vs/workbench/contrib/notebook/browser/contrib/fold/foldingModel
'
;
import
{
MarkdownCellViewModel
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/markdownCellViewModel
'
;
import
{
ICodeEditor
}
from
'
vs/editor/browser/editorBrowser
'
;
...
...
@@ -214,7 +214,7 @@ export class StatefulMarkdownCell extends Disposable {
const
width
=
this
.
viewCell
.
layoutInfo
.
editorWidth
;
const
lineNum
=
this
.
viewCell
.
lineCount
;
const
lineHeight
=
this
.
viewCell
.
layoutInfo
.
fontInfo
?.
lineHeight
||
17
;
editorHeight
=
Math
.
max
(
lineNum
,
1
)
*
lineHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
;
editorHeight
=
Math
.
max
(
lineNum
,
1
)
*
lineHeight
+
getEditorTopPadding
()
+
EDITOR_BOTTOM_PADDING
;
this
.
templateData
.
editorContainer
.
innerText
=
''
;
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/baseCellViewModel.ts
浏览文件 @
e66547a1
...
...
@@ -12,8 +12,8 @@ import { IPosition } from 'vs/editor/common/core/position';
import
*
as
editorCommon
from
'
vs/editor/common/editorCommon
'
;
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
SearchParams
}
from
'
vs/editor/common/model/textModelSearch
'
;
import
{
CELL_STATUSBAR_HEIGHT
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFocusMode
,
CursorAtBoundary
,
CellViewModelStateChangeEvent
,
IEditableCellViewModel
,
INotebookCellDecorationOptions
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CELL_STATUSBAR_HEIGHT
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFocusMode
,
CursorAtBoundary
,
CellViewModelStateChangeEvent
,
IEditableCellViewModel
,
INotebookCellDecorationOptions
,
getEditorTopPadding
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
CellKind
,
NotebookCellMetadata
,
NotebookDocumentMetadata
,
INotebookSearchOptions
,
ShowCellStatusBarKey
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
...
...
@@ -341,7 +341,7 @@ export abstract class BaseCellViewModel extends Disposable {
return
0
;
}
return
this
.
_textEditor
.
getTopForLineNumber
(
line
)
+
EDITOR_TOP_PADDING
;
return
this
.
_textEditor
.
getTopForLineNumber
(
line
)
+
getEditorTopPadding
()
;
}
getPositionScrollTopOffset
(
line
:
number
,
column
:
number
):
number
{
...
...
@@ -349,7 +349,7 @@ export abstract class BaseCellViewModel extends Disposable {
return
0
;
}
return
this
.
_textEditor
.
getTopForPosition
(
line
,
column
)
+
EDITOR_TOP_PADDING
;
return
this
.
_textEditor
.
getTopForPosition
(
line
,
column
)
+
getEditorTopPadding
()
;
}
cursorAtBeginEnd
():
boolean
{
...
...
src/vs/workbench/contrib/notebook/browser/viewModel/codeCellViewModel.ts
浏览文件 @
e66547a1
...
...
@@ -9,8 +9,8 @@ import * as editorCommon from 'vs/editor/common/editorCommon';
import
*
as
model
from
'
vs/editor/common/model
'
;
import
{
PrefixSumComputer
}
from
'
vs/editor/common/viewModel/prefixSumComputer
'
;
import
{
IConfigurationService
}
from
'
vs/platform/configuration/common/configuration
'
;
import
{
BOTTOM_CELL_TOOLBAR_GAP
,
BOTTOM_CELL_TOOLBAR_HEIGHT
,
CELL_BOTTOM_MARGIN
,
CELL_MARGIN
,
CELL_RUN_GUTTER
,
CELL_TOP_MARGIN
,
CODE_CELL_LEFT_MARGIN
,
COLLAPSED_INDICATOR_HEIGHT
,
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
,
EDITOR_TOP_PADDING
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFindMatch
,
CodeCellLayoutChangeEvent
,
CodeCellLayoutInfo
,
CodeCellLayoutState
,
ICellViewModel
,
NotebookLayoutInfo
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
BOTTOM_CELL_TOOLBAR_GAP
,
BOTTOM_CELL_TOOLBAR_HEIGHT
,
CELL_BOTTOM_MARGIN
,
CELL_MARGIN
,
CELL_RUN_GUTTER
,
CELL_TOP_MARGIN
,
CODE_CELL_LEFT_MARGIN
,
COLLAPSED_INDICATOR_HEIGHT
,
EDITOR_BOTTOM_PADDING
,
EDITOR_TOOLBAR_HEIGHT
}
from
'
vs/workbench/contrib/notebook/browser/constants
'
;
import
{
CellEditState
,
CellFindMatch
,
CodeCellLayoutChangeEvent
,
CodeCellLayoutInfo
,
CodeCellLayoutState
,
getEditorTopPadding
,
ICellViewModel
,
NotebookLayoutInfo
}
from
'
vs/workbench/contrib/notebook/browser/notebookBrowser
'
;
import
{
NotebookEventDispatcher
}
from
'
vs/workbench/contrib/notebook/browser/viewModel/eventDispatcher
'
;
import
{
NotebookCellTextModel
}
from
'
vs/workbench/contrib/notebook/common/model/notebookCellTextModel
'
;
import
{
CellKind
,
INotebookSearchOptions
,
NotebookCellOutputsSplice
}
from
'
vs/workbench/contrib/notebook/common/notebookCommon
'
;
...
...
@@ -221,7 +221,7 @@ export class CodeCellViewModel extends BaseCellViewModel implements ICellViewMod
}
private
estimateEditorHeight
(
lineHeight
:
number
|
undefined
=
20
):
number
{
return
this
.
lineCount
*
lineHeight
+
EDITOR_TOP_PADDING
+
EDITOR_BOTTOM_PADDING
;
return
this
.
lineCount
*
lineHeight
+
getEditorTopPadding
()
+
EDITOR_BOTTOM_PADDING
;
}
private
computeTotalHeight
(
editorHeight
:
number
,
outputsTotalHeight
:
number
,
outputShowMoreContainerHeight
:
number
):
number
{
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录