Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add context menu toggle + command pallette #188550

Closed
wants to merge 4 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,6 +145,7 @@ export class MenuId {
static readonly InteractiveCellExecute = new MenuId('InteractiveCellExecute');
static readonly InteractiveInputExecute = new MenuId('InteractiveInputExecute');
static readonly NotebookToolbar = new MenuId('NotebookToolbar');
static readonly NotebookStickyScrollContext = new MenuId('NotebookStickyScrollContext');
static readonly NotebookCellTitle = new MenuId('NotebookCellTitle');
static readonly NotebookCellDelete = new MenuId('NotebookCellDelete');
static readonly NotebookCellInsert = new MenuId('NotebookCellInsert');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
// output is already gone
removedItems.push(key);
} else {
const cellTop = this._list.getAbsoluteTopOfElement(value.cellInfo.diffElement);
const cellTop = this._list.getCellViewScrollTop(value.cellInfo.diffElement);
const outputIndex = cell.outputsViewModels.indexOf(key);
const outputOffset = value.cellInfo.diffElement.getOutputOffsetInCell(diffSide, outputIndex);
updateItems.push({
Expand Down Expand Up @@ -872,10 +872,10 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
}

if (!activeWebview.insetMapping.has(output.source)) {
const cellTop = this._list.getAbsoluteTopOfElement(cellDiffViewModel);
const cellTop = this._list.getCellViewScrollTop(cellDiffViewModel);
await activeWebview.createOutput({ diffElement: cellDiffViewModel, cellHandle: cellViewModel.handle, cellId: cellViewModel.id, cellUri: cellViewModel.uri }, output, cellTop, getOffset());
} else {
const cellTop = this._list.getAbsoluteTopOfElement(cellDiffViewModel);
const cellTop = this._list.getCellViewScrollTop(cellDiffViewModel);
const outputIndex = cellViewModel.outputsViewModels.indexOf(output.source);
const outputOffset = cellDiffViewModel.getOutputOffsetInCell(diffSide, outputIndex);
activeWebview.updateScrollTops([{
Expand Down Expand Up @@ -927,7 +927,7 @@ export class NotebookTextDiffEditor extends EditorPane implements INotebookTextD
return;
}

const cellTop = this._list.getAbsoluteTopOfElement(cellDiffViewModel);
const cellTop = this._list.getCellViewScrollTop(cellDiffViewModel);
const outputIndex = cellViewModel.outputsViewModels.indexOf(displayOutput);
const outputOffset = cellDiffViewModel.getOutputOffsetInCell(diffSide, outputIndex);
activeWebview.updateScrollTops([{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -322,7 +322,7 @@ export class NotebookTextDiffList extends WorkbenchList<DiffElementViewModelBase
return new NotebookMouseController(this);
}

getAbsoluteTopOfElement(element: DiffElementViewModelBase): number {
getCellViewScrollTop(element: DiffElementViewModelBase): number {
const index = this.indexOf(element);
// if (index === undefined || index < 0 || index >= this.length) {
// this._getViewIndexUpperBound(element);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
display: none;
position: absolute;
background-color: var(--vscode-notebook-editorBackground);
border-bottom: solid 1px var(--vscode-notebook-cellToolbarSeparator);
box-sizing: border-box;
z-index: var(--z-index-notebook-sticky-scroll);
width: 100%;
font-family: var(--notebook-cell-input-preview-font-family);
Expand All @@ -27,3 +25,15 @@
background-color: var(--vscode-editorStickyScrollHover-background);
cursor: pointer;
}

.monaco-workbench
.notebookOverlay
.notebook-sticky-scroll-container
.notebook-shadow {
display: block;
top: 0;
left: 3px;
height: 3px;
width: 100%;
box-shadow: var(--vscode-scrollbar-shadow) 0 6px 6px -6px inset;
}
5 changes: 5 additions & 0 deletions src/vs/workbench/contrib/notebook/browser/notebookBrowser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@ export interface INotebookEditor {
*/
removeClassName(className: string): void;

/**
* Set scrollTop value of the notebook editor.
*/
setScrollTop(scrollTop: number): void;

/**
* The range will be revealed with as little scrolling as possible.
*/
Expand Down
20 changes: 12 additions & 8 deletions src/vs/workbench/contrib/notebook/browser/notebookEditorWidget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ import { INotebookLoggingService } from 'vs/workbench/contrib/notebook/common/no
import { Schemas } from 'vs/base/common/network';
import { DropIntoEditorController } from 'vs/editor/contrib/dropOrPasteInto/browser/dropIntoEditorController';
import { CopyPasteController } from 'vs/editor/contrib/dropOrPasteInto/browser/copyPasteController';
import { NotebookEditorStickyScroll } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll';
import { NotebookStickyScroll } from 'vs/workbench/contrib/notebook/browser/viewParts/notebookEditorStickyScroll';
import { NotebookCellOutlineProvider } from 'vs/workbench/contrib/notebook/browser/viewModel/notebookOutlineProvider';
import { AccessibilityVerbositySettingId } from 'vs/workbench/contrib/accessibility/browser/accessibilityContribution';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
Expand Down Expand Up @@ -1046,7 +1046,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
}

private _registerNotebookStickyScroll() {
this._register(this.instantiationService.createInstance(NotebookEditorStickyScroll, this._notebookStickyScrollContainer, this, this._notebookOutline, this._list));
this._register(this.instantiationService.createInstance(NotebookStickyScroll, this._notebookStickyScrollContainer, this, this._notebookOutline, this._list));
}

private _updateOutputRenderers() {
Expand Down Expand Up @@ -2038,13 +2038,17 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
}

getAbsoluteTopOfElement(cell: ICellViewModel) {
return this._list.getAbsoluteTopOfElement(cell);
return this._list.getCellViewScrollTop(cell);
}

scrollToBottom() {
this._list.scrollToBottom();
}

setScrollTop(scrollTop: number): void {
this._list.scrollTop = scrollTop;
}

revealCellRangeInView(range: ICellRange) {
return this._list.revealCellsInView(range);
}
Expand Down Expand Up @@ -2629,7 +2633,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
const webviewTop = parseInt(this._list.webviewElement.domNode.style.top, 10);
const top = !!webviewTop ? (0 - webviewTop) : 0;

const cellTop = this._list.getAbsoluteTopOfElement(cell);
const cellTop = this._list.getCellViewScrollTop(cell);
await this._webview.showMarkupPreview({
mime: cell.mime,
cellHandle: cell.handle,
Expand Down Expand Up @@ -2723,7 +2727,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
const webviewTop = parseInt(this._list.webviewElement.domNode.style.top, 10);
const top = !!webviewTop ? (0 - webviewTop) : 0;

const cellTop = this._list.getAbsoluteTopOfElement(cell) + top;
const cellTop = this._list.getCellViewScrollTop(cell) + top;

const existingOutput = this._webview.insetMapping.get(output.source);
if (!existingOutput
Expand Down Expand Up @@ -2781,7 +2785,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
const webviewTop = parseInt(this._list.webviewElement.domNode.style.top, 10);
const top = !!webviewTop ? (0 - webviewTop) : 0;

const cellTop = this._list.getAbsoluteTopOfElement(cell) + top;
const cellTop = this._list.getCellViewScrollTop(cell) + top;
this._webview.updateOutput({ cellId: cell.id, cellHandle: cell.handle, cellUri: cell.uri }, output, cellTop, offset);
});
}
Expand Down Expand Up @@ -2889,7 +2893,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
removedItems.push(key);
}

const cellTop = this._list.getAbsoluteTopOfElement(cell);
const cellTop = this._list.getCellViewScrollTop(cell);
const outputIndex = cell.outputsViewModels.indexOf(key);
const outputOffset = cell.getOutputOffset(outputIndex);
updateItems.push({
Expand All @@ -2907,7 +2911,7 @@ export class NotebookEditorWidget extends Disposable implements INotebookEditorD
for (const cellId of this._webview.markupPreviewMapping.keys()) {
const cell = this.viewModel?.viewCells.find(cell => cell.id === cellId);
if (cell) {
const cellTop = this._list.getAbsoluteTopOfElement(cell);
const cellTop = this._list.getCellViewScrollTop(cell);
// markdownUpdateItems.push({ id: cellId, top: cellTop });
markdownUpdateItems.push({ id: cellId, top: cellTop + top });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ export class CellDragAndDropController extends Disposable {
return undefined;
}

const cellTop = this.list.getAbsoluteTopOfElement(draggedOverCell);
const cellTop = this.list.getCellViewScrollTop(draggedOverCell);
const cellHeight = this.list.elementHeight(draggedOverCell);

const dragPosInElement = dragOffset - cellTop;
Expand Down Expand Up @@ -228,7 +228,7 @@ export class CellDragAndDropController extends Disposable {
}

private _dropImpl(draggedCell: ICellViewModel, dropDirection: 'above' | 'below', ctx: { ctrlKey: boolean; altKey: boolean }, draggedOverCell: ICellViewModel) {
const cellTop = this.list.getAbsoluteTopOfElement(draggedOverCell);
const cellTop = this.list.getCellViewScrollTop(draggedOverCell);
const cellHeight = this.list.elementHeight(draggedOverCell);
const insertionIndicatorAbsolutePos = dropDirection === 'above' ? cellTop : cellTop + cellHeight;
const { bottomToolbarGap } = this.notebookEditor.notebookOptions.computeBottomToolbarDimensions(this.notebookEditor.textModel?.viewType);
Expand Down Expand Up @@ -358,7 +358,7 @@ export class CellDragAndDropController extends Disposable {

const target = this.list.elementAt(dragOffsetY);
if (target && target !== cell) {
const cellTop = this.list.getAbsoluteTopOfElement(target);
const cellTop = this.list.getCellViewScrollTop(target);
const cellHeight = this.list.elementHeight(target);

const dropDirection = this.getExplicitDragDropDirection(dragOffsetY, cellTop, cellHeight);
Expand Down Expand Up @@ -400,7 +400,7 @@ export class CellDragAndDropController extends Disposable {
return;
}

const cellTop = this.list.getAbsoluteTopOfElement(target);
const cellTop = this.list.getCellViewScrollTop(target);
const cellHeight = this.list.elementHeight(target);
const dropDirection = this.getExplicitDragDropDirection(ctx.dragOffsetY, cellTop, cellHeight);
this._dropImpl(cell, dropDirection, ctx, target);
Expand Down
10 changes: 0 additions & 10 deletions src/vs/workbench/contrib/notebook/browser/view/notebookCellList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1131,16 +1131,6 @@ export class NotebookCellList extends WorkbenchList<CellViewModel> implements ID
this.view.domNode.focus();
}

getAbsoluteTopOfElement(element: ICellViewModel): number {
const index = this._getViewIndexUpperBound(element);
if (index === undefined || index < 0 || index >= this.length) {
this._getViewIndexUpperBound(element);
throw new ListError(this.listUser, `Invalid index ${index}`);
}

return this.view.elementTop(index);
}

triggerScrollFromMouseWheelEvent(browserEvent: IMouseWheelEvent) {
this.view.delegateScrollFromMouseWheelEvent(browserEvent);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,6 @@ export interface INotebookCellList {
setHiddenAreas(_ranges: ICellRange[], triggerViewUpdate: boolean): boolean;
domElementOfElement(element: ICellViewModel): HTMLElement | null;
focusView(): void;
getAbsoluteTopOfElement(element: ICellViewModel): number;
triggerScrollFromMouseWheelEvent(browserEvent: IMouseWheelEvent): void;
updateElementHeight2(element: ICellViewModel, size: number, anchorElementIndex?: number | null): void;
domFocus(): void;
Expand Down
Loading
Loading