@@ -18,7 +18,7 @@ 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' ;
20
20
import { IContextMenuService , IContextViewService } from 'vs/platform/contextview/browser/contextView' ;
21
- import { editorWidgetBackground , editorWidgetForeground , inputActiveOptionBackground , inputActiveOptionBorder , inputActiveOptionForeground , inputBackground , inputBorder , inputForeground , inputValidationErrorBackground , inputValidationErrorBorder , inputValidationErrorForeground , inputValidationInfoBackground , inputValidationInfoBorder , inputValidationInfoForeground , inputValidationWarningBackground , inputValidationWarningBorder , inputValidationWarningForeground , widgetShadow } from 'vs/platform/theme/common/colorRegistry' ;
21
+ import { editorWidgetBackground , editorWidgetBorder , editorWidgetForeground , editorWidgetResizeBorder , inputActiveOptionBackground , inputActiveOptionBorder , inputActiveOptionForeground , inputBackground , inputBorder , inputForeground , inputValidationErrorBackground , inputValidationErrorBorder , inputValidationErrorForeground , inputValidationInfoBackground , inputValidationInfoBorder , inputValidationInfoForeground , inputValidationWarningBackground , inputValidationWarningBorder , inputValidationWarningForeground , widgetShadow } from 'vs/platform/theme/common/colorRegistry' ;
22
22
import { registerIcon , widgetClose } from 'vs/platform/theme/common/iconRegistry' ;
23
23
import { attachProgressBarStyler } from 'vs/platform/theme/common/styler' ;
24
24
import { IColorTheme , IThemeService , registerThemingParticipant , ThemeIcon } from 'vs/platform/theme/common/themeService' ;
@@ -35,6 +35,8 @@ 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 } from 'vs/base/browser/ui/sash/sash' ;
39
+ import { INotebookEditor } from 'vs/workbench/contrib/notebook/browser/notebookBrowser' ;
38
40
39
41
const NLS_FIND_INPUT_LABEL = nls . localize ( 'label.find' , "Find" ) ;
40
42
const NLS_FIND_INPUT_PLACEHOLDER = nls . localize ( 'placeholder.find' , "Find" ) ;
@@ -55,6 +57,8 @@ const NOTEBOOK_FIND_IN_MARKUP_PREVIEW = nls.localize('notebook.find.filter.findI
55
57
const NOTEBOOK_FIND_IN_CODE_INPUT = nls . localize ( 'notebook.find.filter.findInCodeInput' , "Code Cell Source" ) ;
56
58
const NOTEBOOK_FIND_IN_CODE_OUTPUT = nls . localize ( 'notebook.find.filter.findInCodeOutput' , "Cell Output" ) ;
57
59
60
+ const NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH = 318 ;
61
+ const NOTEBOOK_FIND_WIDGET_INITIAL_HORIZONTAL_PADDING = 4 ;
58
62
class NotebookFindFilterActionViewItem extends DropdownMenuActionViewItem {
59
63
constructor ( readonly filters : NotebookFindFilters , action : IAction , actionRunner : IActionRunner , @IContextMenuService contextMenuService : IContextMenuService ) {
60
64
super ( action ,
@@ -256,6 +260,8 @@ export abstract class SimpleFindReplaceWidget extends Widget {
256
260
protected _replaceBtn ! : SimpleButton ;
257
261
protected _replaceAllBtn ! : SimpleButton ;
258
262
263
+ private readonly _resizeSash : Sash ;
264
+ private _resizeOriginalWidth = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ;
259
265
260
266
private _isVisible : boolean = false ;
261
267
private _isReplaceVisible : boolean = false ;
@@ -274,7 +280,8 @@ export abstract class SimpleFindReplaceWidget extends Widget {
274
280
@IMenuService readonly menuService : IMenuService ,
275
281
@IContextMenuService readonly contextMenuService : IContextMenuService ,
276
282
@IInstantiationService readonly instantiationService : IInstantiationService ,
277
- protected readonly _state : FindReplaceState < NotebookFindFilters > = new FindReplaceState < NotebookFindFilters > ( )
283
+ protected readonly _state : FindReplaceState < NotebookFindFilters > = new FindReplaceState < NotebookFindFilters > ( ) ,
284
+ protected readonly _notebookEditor : INotebookEditor ,
278
285
) {
279
286
super ( ) ;
280
287
@@ -339,7 +346,8 @@ export abstract class SimpleFindReplaceWidget extends Widget {
339
346
this . updateButtons ( this . foundMatch ) ;
340
347
return { content : e . message } ;
341
348
}
342
- }
349
+ } ,
350
+ flexibleWidth : true ,
343
351
}
344
352
) ) ;
345
353
@@ -474,6 +482,58 @@ export abstract class SimpleFindReplaceWidget extends Widget {
474
482
475
483
this . _innerReplaceDomNode . appendChild ( this . _replaceBtn . domNode ) ;
476
484
this . _innerReplaceDomNode . appendChild ( this . _replaceAllBtn . domNode ) ;
485
+
486
+ this . _resizeSash = this . _register ( new Sash ( this . _domNode , { getVerticalSashLeft : ( ) => 0 } , { orientation : Orientation . VERTICAL , size : 2 } ) ) ;
487
+
488
+ this . _register ( this . _resizeSash . onDidStart ( ( ) => {
489
+ this . _resizeOriginalWidth = this . _getDomWidth ( ) ;
490
+ } ) ) ;
491
+
492
+ this . _register ( this . _resizeSash . onDidChange ( ( evt : ISashEvent ) => {
493
+ let width = this . _resizeOriginalWidth + evt . startX - evt . currentX ;
494
+ if ( width < NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ) {
495
+ width = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ;
496
+ }
497
+
498
+ const maxWidth = this . _getMaxWidth ( ) ;
499
+ if ( width > maxWidth ) {
500
+ width = maxWidth ;
501
+ }
502
+
503
+ this . _domNode . style . width = `${ width } px` ;
504
+
505
+ if ( this . _isReplaceVisible ) {
506
+ this . _replaceInput . width = dom . getTotalWidth ( this . _findInput . domNode ) ;
507
+ }
508
+
509
+ this . _findInput . inputBox . layout ( ) ;
510
+ } ) ) ;
511
+
512
+ this . _register ( this . _resizeSash . onDidReset ( ( ) => {
513
+ // users double click on the sash
514
+ // try to emulate what happens with editor findWidget
515
+ const currentWidth = this . _getDomWidth ( ) ;
516
+ let width = NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ;
517
+
518
+ if ( currentWidth <= NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH ) {
519
+ width = this . _getMaxWidth ( ) ;
520
+ }
521
+
522
+ this . _domNode . style . width = `${ width } px` ;
523
+ if ( this . _isReplaceVisible ) {
524
+ this . _replaceInput . width = dom . getTotalWidth ( this . _findInput . domNode ) ;
525
+ }
526
+
527
+ this . _findInput . inputBox . layout ( ) ;
528
+ } ) ) ;
529
+ }
530
+
531
+ private _getMaxWidth ( ) {
532
+ return this . _notebookEditor . getLayoutInfo ( ) . width - 64 ;
533
+ }
534
+
535
+ private _getDomWidth ( ) {
536
+ return dom . getTotalWidth ( this . _domNode ) - ( NOTEBOOK_FIND_WIDGET_INITIAL_HORIZONTAL_PADDING * 2 ) ;
477
537
}
478
538
479
539
getCellToolbarActions ( menu : IMenu ) : { primary : IAction [ ] ; secondary : IAction [ ] } {
@@ -727,4 +787,16 @@ registerThemingParticipant((theme, collector) => {
727
787
if ( inputActiveOptionBackgroundColor ) {
728
788
collector . addRule ( `.simple-fr-find-part .find-filter-button > .monaco-action-bar .action-label.notebook-filters.checked { background-color: ${ inputActiveOptionBackgroundColor } ; }` ) ;
729
789
}
790
+
791
+ const resizeBorderBackground = theme . getColor ( editorWidgetResizeBorder ) ?? theme . getColor ( editorWidgetBorder ) ;
792
+ if ( resizeBorderBackground ) {
793
+ collector . addRule ( `.monaco-workbench .simple-fr-find-part-wrapper .monaco-sash { background-color: ${ resizeBorderBackground } ; }` ) ;
794
+ }
795
+
796
+ collector . addRule ( `
797
+ :root {
798
+ --notebook-find-width: ${ NOTEBOOK_FIND_WIDGET_INITIAL_WIDTH } px;
799
+ --notebook-find-horizontal-padding: ${ NOTEBOOK_FIND_WIDGET_INITIAL_HORIZONTAL_PADDING } px;
800
+ }
801
+ ` ) ;
730
802
} ) ;
0 commit comments