@@ -58,7 +58,8 @@ const NOTEBOOK_FIND_IN_MARKUP_PREVIEW = nls.localize('notebook.find.filter.findI
58
58
const NOTEBOOK_FIND_IN_CODE_INPUT = nls . localize ( 'notebook.find.filter.findInCodeInput' , "Code Cell Source" ) ;
59
59
const NOTEBOOK_FIND_IN_CODE_OUTPUT = nls . localize ( 'notebook.find.filter.findInCodeOutput' , "Cell Output" ) ;
60
60
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 ;
62
63
class NotebookFindFilterActionViewItem extends DropdownMenuActionViewItem {
63
64
constructor ( readonly filters : NotebookFindFilters , action : IAction , actionRunner : IActionRunner , @IContextMenuService contextMenuService : IContextMenuService ) {
64
65
super ( action ,
@@ -260,10 +261,9 @@ export abstract class SimpleFindReplaceWidget extends Widget {
260
261
protected _replaceBtn ! : SimpleButton ;
261
262
protected _replaceAllBtn ! : SimpleButton ;
262
263
263
- private readonly _westSash : Sash ;
264
- private _resized : boolean = false ;
264
+ private readonly _resizeSash : Sash ;
265
265
private readonly _sashListener = new DisposableStore ( ) ;
266
-
266
+ private _resizeOriginalWidth = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ;
267
267
268
268
private _isVisible : boolean = false ;
269
269
private _isReplaceVisible : boolean = false ;
@@ -485,44 +485,59 @@ export abstract class SimpleFindReplaceWidget extends Widget {
485
485
this . _innerReplaceDomNode . appendChild ( this . _replaceBtn . domNode ) ;
486
486
this . _innerReplaceDomNode . appendChild ( this . _replaceAllBtn . domNode ) ;
487
487
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 } ) ;
491
489
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 ( ) ;
494
492
} ) ) ;
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 ;
498
496
if ( width < NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ) {
499
- return ;
497
+ width = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ;
500
498
}
501
499
502
500
const maxWidth = this . _getMaxWidth ( ) ;
503
501
if ( width > maxWidth ) {
504
- return ;
502
+ width = maxWidth ;
505
503
}
506
504
507
505
this . _domNode . style . width = `${ width } px` ;
506
+
508
507
if ( this . _isReplaceVisible ) {
509
508
this . _replaceInput . width = dom . getTotalWidth ( this . _findInput . domNode ) ;
510
509
}
510
+
511
511
this . _findInput . inputBox . layout ( ) ;
512
512
} ) ) ;
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 ( ) ;
520
530
} ) ) ;
521
531
}
522
532
523
533
private _getMaxWidth ( ) {
524
534
return this . _notebookEditor . getLayoutInfo ( ) . width - 64 ;
525
535
}
536
+
537
+ private _getDomWidth ( ) {
538
+ return dom . getTotalWidth ( this . _domNode ) - ( NOTEBOOK_FIND_WIDGET_INITIAL_HORIZONTAL_PADDING * 2 ) ;
539
+ }
540
+
526
541
getCellToolbarActions ( menu : IMenu ) : { primary : IAction [ ] ; secondary : IAction [ ] } {
527
542
const primary : IAction [ ] = [ ] ;
528
543
const secondary : IAction [ ] = [ ] ;
@@ -788,6 +803,7 @@ registerThemingParticipant((theme, collector) => {
788
803
collector . addRule ( `
789
804
:root {
790
805
--notebook-find-width: ${ NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH } px;
806
+ --notebook-find-horizontal-padding: ${ NOTEBOOK_FIND_WIDGET_INITIAL_HORIZONTAL_PADDING } px;
791
807
}
792
808
` ) ;
793
809
} ) ;
0 commit comments