Skip to content

Commit d275e7b

Browse files
committed
Unable to expand find menu in notebook editor
Fixes #141516
1 parent 8b008df commit d275e7b

File tree

2 files changed

+38
-22
lines changed

2 files changed

+38
-22
lines changed

src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
right: 18px;
1212
width: var(--notebook-find-width);
1313
max-width: calc(100% - 28px - 28px - 8px);
14-
padding:0 4px;
14+
padding:0 var(--notebook-find-horizontal-padding);
1515
transition: top 200ms linear;
1616
visibility: hidden;
1717
}

src/vs/workbench/contrib/notebook/browser/contrib/find/notebookFindReplaceWidget.ts

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ const NOTEBOOK_FIND_IN_MARKUP_PREVIEW = nls.localize('notebook.find.filter.findI
5858
const NOTEBOOK_FIND_IN_CODE_INPUT = nls.localize('notebook.find.filter.findInCodeInput', "Code Cell Source");
5959
const NOTEBOOK_FIND_IN_CODE_OUTPUT = nls.localize('notebook.find.filter.findInCodeOutput', "Cell Output");
6060

61-
const NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH = 318;
61+
const NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH = 322;
62+
const NOTEBOOK_FIND_WIDGET_INITIAL_HORIZONTAL_PADDING = 4;
6263
class NotebookFindFilterActionViewItem extends DropdownMenuActionViewItem {
6364
constructor(readonly filters: NotebookFindFilters, action: IAction, actionRunner: IActionRunner, @IContextMenuService contextMenuService: IContextMenuService) {
6465
super(action,
@@ -260,10 +261,9 @@ export abstract class SimpleFindReplaceWidget extends Widget {
260261
protected _replaceBtn!: SimpleButton;
261262
protected _replaceAllBtn!: SimpleButton;
262263

263-
private readonly _westSash: Sash;
264-
private _resized: boolean = false;
264+
private readonly _resizeSash: Sash;
265265
private readonly _sashListener = new DisposableStore();
266-
266+
private _resizeOriginalWidth = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH;
267267

268268
private _isVisible: boolean = false;
269269
private _isReplaceVisible: boolean = false;
@@ -485,44 +485,59 @@ export abstract class SimpleFindReplaceWidget extends Widget {
485485
this._innerReplaceDomNode.appendChild(this._replaceBtn.domNode);
486486
this._innerReplaceDomNode.appendChild(this._replaceAllBtn.domNode);
487487

488-
this._westSash = new Sash(this._domNode, { getVerticalSashLeft: () => 0 }, { orientation: Orientation.VERTICAL, size: 2 });
489-
490-
let originalWidth = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH;
488+
this._resizeSash = new Sash(this._domNode, { getVerticalSashLeft: () => 0 }, { orientation: Orientation.VERTICAL, size: 2 });
491489

492-
this._sashListener.add(this._westSash.onDidStart(() => {
493-
originalWidth = dom.getTotalWidth(this._domNode);
490+
this._sashListener.add(this._resizeSash.onDidStart(() => {
491+
this._resizeOriginalWidth = this._getDomWidth();
494492
}));
495-
this._sashListener.add(this._westSash.onDidChange((evt: ISashEvent) => {
496-
this._resized = true;
497-
const width = originalWidth + evt.startX - evt.currentX;
493+
494+
this._sashListener.add(this._resizeSash.onDidChange((evt: ISashEvent) => {
495+
let width = this._resizeOriginalWidth + evt.startX - evt.currentX;
498496
if (width < NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH) {
499-
return;
497+
width = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH;
500498
}
501499

502500
const maxWidth = this._getMaxWidth();
503501
if (width > maxWidth) {
504-
return;
502+
width = maxWidth;
505503
}
506504

507505
this._domNode.style.width = `${width}px`;
506+
508507
if (this._isReplaceVisible) {
509508
this._replaceInput.width = dom.getTotalWidth(this._findInput.domNode);
510509
}
510+
511511
this._findInput.inputBox.layout();
512512
}));
513-
this._sashListener.add(this._westSash.onDidReset(() => {
514-
// this._domNode.style.width = `${NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH}px`;
515-
const layoutInfo = this._notebookEditor.getLayoutInfo();
516-
console.log(layoutInfo);
517-
console.log(this._domNode.style.width);
518-
// const layoutInfo = notebookEditor
519-
// width = layoutInfo.width - 28 - layoutInfo.minimap.minimapWidth - 15;
513+
514+
this._sashListener.add(this._resizeSash.onDidReset(() => {
515+
// users double click on the sash
516+
// try to emulate what happens with editor findWidget
517+
const currentWidth = this._getDomWidth();
518+
let width = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH;
519+
520+
if (currentWidth <= NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH) {
521+
width = this._getMaxWidth();
522+
}
523+
524+
this._domNode.style.width = `${width}px`;
525+
if (this._isReplaceVisible) {
526+
this._replaceInput.width = dom.getTotalWidth(this._findInput.domNode);
527+
}
528+
529+
this._findInput.inputBox.layout();
520530
}));
521531
}
522532

523533
private _getMaxWidth() {
524534
return this._notebookEditor.getLayoutInfo().width - 64;
525535
}
536+
537+
private _getDomWidth() {
538+
return dom.getTotalWidth(this._domNode) - (NOTEBOOK_FIND_WIDGET_INITIAL_HORIZONTAL_PADDING * 2);
539+
}
540+
526541
getCellToolbarActions(menu: IMenu): { primary: IAction[]; secondary: IAction[] } {
527542
const primary: IAction[] = [];
528543
const secondary: IAction[] = [];
@@ -788,6 +803,7 @@ registerThemingParticipant((theme, collector) => {
788803
collector.addRule(`
789804
:root {
790805
--notebook-find-width: ${NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH}px;
806+
--notebook-find-horizontal-padding: ${NOTEBOOK_FIND_WIDGET_INITIAL_HORIZONTAL_PADDING}px;
791807
}
792808
`);
793809
});

0 commit comments

Comments
 (0)