@@ -13,7 +13,7 @@ import { Delayer } from 'vs/base/common/async';
13
13
import { KeyCode } from 'vs/base/common/keyCodes' ;
14
14
import 'vs/css!./notebookFindReplaceWidget' ;
15
15
import { FindReplaceState , FindReplaceStateChangedEvent } from 'vs/editor/contrib/find/browser/findState' ;
16
- import { findNextMatchIcon , findPreviousMatchIcon , findReplaceAllIcon , findReplaceIcon , FIND_WIDGET_INITIAL_WIDTH , SimpleButton } from 'vs/editor/contrib/find/browser/findWidget' ;
16
+ import { findNextMatchIcon , findPreviousMatchIcon , findReplaceAllIcon , findReplaceIcon , SimpleButton } from 'vs/editor/contrib/find/browser/findWidget' ;
17
17
import * as nls from 'vs/nls' ;
18
18
import { ContextScopedReplaceInput , registerAndCreateHistoryNavigationContext } from 'vs/platform/history/browser/contextScopedHistoryWidget' ;
19
19
import { IContextKeyService } from 'vs/platform/contextkey/common/contextkey' ;
@@ -35,8 +35,9 @@ import { ActionBar } from 'vs/base/browser/ui/actionbar/actionbar';
35
35
import { filterIcon } from 'vs/workbench/contrib/extensions/browser/extensionsIcons' ;
36
36
import { NotebookFindFilters } from 'vs/workbench/contrib/notebook/browser/contrib/find/findFilters' ;
37
37
import { isSafari } from 'vs/base/common/platform' ;
38
- import { ISashEvent , Orientation , Sash , SashState } from 'vs/base/browser/ui/sash/sash' ;
38
+ import { ISashEvent , Orientation , Sash } from 'vs/base/browser/ui/sash/sash' ;
39
39
import { DisposableStore } from 'vs/base/common/lifecycle' ;
40
+ import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
40
41
41
42
const NLS_FIND_INPUT_LABEL = nls . localize ( 'label.find' , "Find" ) ;
42
43
const NLS_FIND_INPUT_PLACEHOLDER = nls . localize ( 'placeholder.find' , "Find" ) ;
@@ -57,6 +58,7 @@ const NOTEBOOK_FIND_IN_MARKUP_PREVIEW = nls.localize('notebook.find.filter.findI
57
58
const NOTEBOOK_FIND_IN_CODE_INPUT = nls . localize ( 'notebook.find.filter.findInCodeInput' , "Code Cell Source" ) ;
58
59
const NOTEBOOK_FIND_IN_CODE_OUTPUT = nls . localize ( 'notebook.find.filter.findInCodeOutput' , "Cell Output" ) ;
59
60
61
+ const NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH = 318 ;
60
62
class NotebookFindFilterActionViewItem extends DropdownMenuActionViewItem {
61
63
constructor ( readonly filters : NotebookFindFilters , action : IAction , actionRunner : IActionRunner , @IContextMenuService contextMenuService : IContextMenuService ) {
62
64
super ( action ,
@@ -257,11 +259,12 @@ export abstract class SimpleFindReplaceWidget extends Widget {
257
259
private readonly _replaceInputFocusTracker ! : dom . IFocusTracker ;
258
260
protected _replaceBtn ! : SimpleButton ;
259
261
protected _replaceAllBtn ! : SimpleButton ;
262
+
260
263
private readonly _westSash : Sash ;
264
+ private _resized : boolean = false ;
261
265
private readonly _sashListener = new DisposableStore ( ) ;
262
266
263
267
264
-
265
268
private _isVisible : boolean = false ;
266
269
private _isReplaceVisible : boolean = false ;
267
270
private foundMatch : boolean = false ;
@@ -279,7 +282,8 @@ export abstract class SimpleFindReplaceWidget extends Widget {
279
282
@IMenuService readonly menuService : IMenuService ,
280
283
@IContextMenuService readonly contextMenuService : IContextMenuService ,
281
284
@IInstantiationService readonly instantiationService : IInstantiationService ,
282
- protected readonly _state : FindReplaceState < NotebookFindFilters > = new FindReplaceState < NotebookFindFilters > ( )
285
+ protected readonly _state : FindReplaceState < NotebookFindFilters > = new FindReplaceState < NotebookFindFilters > ( ) ,
286
+ protected readonly _notebookEditor : INotebookEditor ,
283
287
) {
284
288
super ( ) ;
285
289
@@ -291,7 +295,6 @@ export abstract class SimpleFindReplaceWidget extends Widget {
291
295
} ) ;
292
296
293
297
this . _domNode = document . createElement ( 'div' ) ;
294
-
295
298
this . _domNode . classList . add ( 'simple-fr-find-part-wrapper' ) ;
296
299
this . _register ( this . _state . onFindReplaceStateChange ( ( e ) => this . _onStateChanged ( e ) ) ) ;
297
300
this . _scopedContextKeyService = contextKeyService . createScoped ( this . _domNode ) ;
@@ -347,8 +350,6 @@ export abstract class SimpleFindReplaceWidget extends Widget {
347
350
}
348
351
} ,
349
352
flexibleWidth : true ,
350
- flexibleHeight : true ,
351
- flexibleMaxHeight : 118 ,
352
353
}
353
354
) ) ;
354
355
@@ -483,19 +484,25 @@ export abstract class SimpleFindReplaceWidget extends Widget {
483
484
484
485
this . _innerReplaceDomNode . appendChild ( this . _replaceBtn . domNode ) ;
485
486
this . _innerReplaceDomNode . appendChild ( this . _replaceAllBtn . domNode ) ;
486
- this . handleFlexWidth ( ) ;
487
487
488
488
this . _westSash = new Sash ( this . _domNode , { getVerticalSashLeft : ( ) => 0 } , { orientation : Orientation . VERTICAL , size : 2 } ) ;
489
489
490
- let originalWidth = FIND_WIDGET_INITIAL_WIDTH ;
490
+ let originalWidth = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ;
491
+
491
492
this . _sashListener . add ( this . _westSash . onDidStart ( ( ) => {
492
493
originalWidth = dom . getTotalWidth ( this . _domNode ) ;
493
494
} ) ) ;
494
- this . _sashListener . add ( this . _westSash . onDidEnd ( ( ) => {
495
- console . log ( 'end' ) ;
496
- } ) ) ;
497
495
this . _sashListener . add ( this . _westSash . onDidChange ( ( evt : ISashEvent ) => {
496
+ this . _resized = true ;
498
497
const width = originalWidth + evt . startX - evt . currentX ;
498
+ if ( width < NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ) {
499
+ return ;
500
+ }
501
+
502
+ const maxWidth = this . _getMaxWidth ( ) ;
503
+ if ( width > maxWidth ) {
504
+ return ;
505
+ }
499
506
500
507
this . _domNode . style . width = `${ width } px` ;
501
508
if ( this . _isReplaceVisible ) {
@@ -504,15 +511,18 @@ export abstract class SimpleFindReplaceWidget extends Widget {
504
511
this . _findInput . inputBox . layout ( ) ;
505
512
} ) ) ;
506
513
this . _sashListener . add ( this . _westSash . onDidReset ( ( ) => {
507
- console . log ( 'reset' ) ;
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;
508
520
} ) ) ;
509
- this . _westSash . state = SashState . Enabled ;
510
521
}
511
522
512
- // getVerticalSashLeft(sash: Sash): number {
513
- // return 4;
514
- // }
515
-
523
+ private _getMaxWidth ( ) {
524
+ return this . _notebookEditor . getLayoutInfo ( ) . width - 64 ;
525
+ }
516
526
getCellToolbarActions ( menu : IMenu ) : { primary : IAction [ ] ; secondary : IAction [ ] } {
517
527
const primary : IAction [ ] = [ ] ;
518
528
const secondary : IAction [ ] = [ ] ;
@@ -612,38 +622,6 @@ export abstract class SimpleFindReplaceWidget extends Widget {
612
622
this . updateButtons ( this . foundMatch ) ;
613
623
}
614
624
615
- private handleFlexWidth ( ) {
616
-
617
- // this._resizeSash = new Sash(this._domNode, this, { orientation: Orientation.VERTICAL, size: 2 });
618
- // let originalWidth = FIND_WIDGET_INITIAL_WIDTH;
619
-
620
- // this._register(this._resizeSash.onDidStart(() => {
621
- // originalWidth = dom.getTotalWidth(this._domNode);
622
- // }));
623
-
624
- // this._register(this._resizeSash.onDidChange((evt: ISashEvent) => {
625
- // const width = originalWidth + evt.startX - evt.currentX;
626
-
627
- // if (width < FIND_WIDGET_INITIAL_WIDTH) {
628
- // // narrow down the find widget should be handled by CSS.
629
- // return;
630
- // }
631
-
632
- // const maxWidth = parseFloat(dom.getComputedStyle(this._domNode).maxWidth!) || 0;
633
- // if (width > maxWidth) {
634
- // return;
635
- // }
636
- // this._domNode.style.width = `${width}px`;
637
- // if (this._isReplaceVisible) {
638
- // this._replaceInput.width = dom.getTotalWidth(this._findInput.domNode);
639
- // }
640
-
641
- // this._findInput.inputBox.layout();
642
- // }));
643
- // look more into findController
644
- // why does the other findWidget trigger constructor every time you open find menu
645
- // how to get sash div element
646
- }
647
625
protected _updateMatchesCount ( ) : void {
648
626
}
649
627
@@ -806,4 +784,10 @@ registerThemingParticipant((theme, collector) => {
806
784
collector . addRule ( `.monaco-workbench .simple-fr-find-part-wrapper .monaco-sash { background-color: ${ border } ; }` ) ;
807
785
}
808
786
}
787
+
788
+ collector . addRule ( `
789
+ :root {
790
+ --notebook-find-width: ${ NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH } px;
791
+ }
792
+ ` ) ;
809
793
} ) ;
0 commit comments