提交 79be3ae1 编写于 作者: R rebornix

Fix #20768. seedSearchStringFromSelection is now an option.

上级 87c24f2b
...@@ -257,6 +257,11 @@ const editorConfiguration: IConfigurationNode = { ...@@ -257,6 +257,11 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.viewInfo.minimap.maxColumn, 'default': EDITOR_DEFAULTS.viewInfo.minimap.maxColumn,
'description': nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns") 'description': nls.localize('minimap.maxColumn', "Limit the width of the minimap to render at most a certain number of columns")
}, },
'editor.find.seedSearchStringFromSelection': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.find.seedSearchStringFromSelection,
'description': nls.localize('find.seedSearchStringFromSelection', "")
},
'editor.wordWrap': { 'editor.wordWrap': {
'type': 'string', 'type': 'string',
'enum': ['off', 'on', 'wordWrapColumn', 'bounded'], 'enum': ['off', 'on', 'wordWrapColumn', 'bounded'],
......
...@@ -74,6 +74,13 @@ export interface IEditorScrollbarOptions { ...@@ -74,6 +74,13 @@ export interface IEditorScrollbarOptions {
horizontalSliderSize?: number; horizontalSliderSize?: number;
} }
/**
* Configuration options for editor find widget
*/
export interface IEditorFindOptions {
seedSearchStringFromSelection?: boolean;
}
/** /**
* Configuration options for editor minimap * Configuration options for editor minimap
*/ */
...@@ -186,6 +193,10 @@ export interface IEditorOptions { ...@@ -186,6 +193,10 @@ export interface IEditorOptions {
* Control the behavior and rendering of the minimap. * Control the behavior and rendering of the minimap.
*/ */
minimap?: IEditorMinimapOptions; minimap?: IEditorMinimapOptions;
/**
* Control the behavior of the find widget.
*/
find?: IEditorFindOptions;
/** /**
* Display overflow widgets as `fixed`. * Display overflow widgets as `fixed`.
* Defaults to `false`. * Defaults to `false`.
...@@ -672,6 +683,10 @@ export interface InternalEditorMinimapOptions { ...@@ -672,6 +683,10 @@ export interface InternalEditorMinimapOptions {
readonly maxColumn: number; readonly maxColumn: number;
} }
export interface InternalEditorFindOptions {
readonly seedSearchStringFromSelection: boolean;
}
export interface EditorWrappingInfo { export interface EditorWrappingInfo {
readonly inDiffEditor: boolean; readonly inDiffEditor: boolean;
readonly isDominatedByLongLines: boolean; readonly isDominatedByLongLines: boolean;
...@@ -738,6 +753,7 @@ export interface EditorContribOptions { ...@@ -738,6 +753,7 @@ export interface EditorContribOptions {
readonly folding: boolean; readonly folding: boolean;
readonly showFoldingControls: 'always' | 'mouseover'; readonly showFoldingControls: 'always' | 'mouseover';
readonly matchBrackets: boolean; readonly matchBrackets: boolean;
readonly find: InternalEditorFindOptions;
} }
/** /**
...@@ -1004,6 +1020,16 @@ export class InternalEditorOptions { ...@@ -1004,6 +1020,16 @@ export class InternalEditorOptions {
return true; return true;
} }
/**
* @internal
*/
private static _equalFindOptions(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean {
return (
a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
);
}
/** /**
* @internal * @internal
*/ */
...@@ -1048,6 +1074,7 @@ export class InternalEditorOptions { ...@@ -1048,6 +1074,7 @@ export class InternalEditorOptions {
&& a.folding === b.folding && a.folding === b.folding
&& a.showFoldingControls === b.showFoldingControls && a.showFoldingControls === b.showFoldingControls
&& a.matchBrackets === b.matchBrackets && a.matchBrackets === b.matchBrackets
&& this._equalFindOptions(a.find, b.find)
); );
} }
...@@ -1413,6 +1440,16 @@ export class EditorOptionsValidator { ...@@ -1413,6 +1440,16 @@ export class EditorOptionsValidator {
}; };
} }
private static _santizeFindOpts(opts: IEditorFindOptions, defaults: InternalEditorFindOptions): InternalEditorFindOptions {
if (typeof opts !== 'object') {
return defaults;
}
return {
seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection)
};
}
private static _sanitizeViewInfo(opts: IEditorOptions, defaults: InternalEditorViewOptions): InternalEditorViewOptions { private static _sanitizeViewInfo(opts: IEditorOptions, defaults: InternalEditorViewOptions): InternalEditorViewOptions {
let rulers: number[] = []; let rulers: number[] = [];
...@@ -1524,6 +1561,7 @@ export class EditorOptionsValidator { ...@@ -1524,6 +1561,7 @@ export class EditorOptionsValidator {
} else { } else {
quickSuggestions = _boolean(opts.quickSuggestions, defaults.quickSuggestions); quickSuggestions = _boolean(opts.quickSuggestions, defaults.quickSuggestions);
} }
const find = this._santizeFindOpts(opts.find, defaults.find);
return { return {
selectionClipboard: _boolean(opts.selectionClipboard, defaults.selectionClipboard), selectionClipboard: _boolean(opts.selectionClipboard, defaults.selectionClipboard),
hover: _boolean(opts.hover, defaults.hover), hover: _boolean(opts.hover, defaults.hover),
...@@ -1547,6 +1585,7 @@ export class EditorOptionsValidator { ...@@ -1547,6 +1585,7 @@ export class EditorOptionsValidator {
folding: !performanceCritical && _boolean(opts.folding, defaults.folding), folding: !performanceCritical && _boolean(opts.folding, defaults.folding),
showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']), showFoldingControls: _stringSet<'always' | 'mouseover'>(opts.showFoldingControls, defaults.showFoldingControls, ['always', 'mouseover']),
matchBrackets: !performanceCritical && _boolean(opts.matchBrackets, defaults.matchBrackets), matchBrackets: !performanceCritical && _boolean(opts.matchBrackets, defaults.matchBrackets),
find: find
}; };
} }
} }
...@@ -1955,5 +1994,8 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = { ...@@ -1955,5 +1994,8 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
folding: true, folding: true,
showFoldingControls: 'mouseover', showFoldingControls: 'mouseover',
matchBrackets: true, matchBrackets: true,
find: {
seedSearchStringFromSelection: true
}
}, },
}; };
...@@ -246,8 +246,10 @@ export class FindWidget extends Widget implements IOverlayWidget { ...@@ -246,8 +246,10 @@ export class FindWidget extends Widget implements IOverlayWidget {
} }
if (e.isRevealed) { if (e.isRevealed) {
if (this._state.isRevealed) { if (this._state.isRevealed) {
console.log('open find widget');
this._reveal(true); this._reveal(true);
} else { } else {
console.log('close find widget');
this._hide(true); this._hide(true);
} }
} }
......
...@@ -235,7 +235,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd ...@@ -235,7 +235,7 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
}; };
// Consider editor selection and overwrite the state with it // Consider editor selection and overwrite the state with it
if (opts.seedSearchStringFromSelection) { if (opts.seedSearchStringFromSelection && this._editor.getConfiguration().contribInfo.find.seedSearchStringFromSelection) {
let selectionSearchString = this.getSelectionSearchString(); let selectionSearchString = this.getSelectionSearchString();
if (selectionSearchString) { if (selectionSearchString) {
if (this._state.isRegex) { if (this._state.isRegex) {
......
...@@ -2627,6 +2627,13 @@ declare module monaco.editor { ...@@ -2627,6 +2627,13 @@ declare module monaco.editor {
horizontalSliderSize?: number; horizontalSliderSize?: number;
} }
/**
* Configuration options for editor find widget
*/
export interface IEditorFindOptions {
seedSearchStringFromSelection?: boolean;
}
/** /**
* Configuration options for editor minimap * Configuration options for editor minimap
*/ */
...@@ -2734,6 +2741,10 @@ declare module monaco.editor { ...@@ -2734,6 +2741,10 @@ declare module monaco.editor {
* Control the behavior and rendering of the minimap. * Control the behavior and rendering of the minimap.
*/ */
minimap?: IEditorMinimapOptions; minimap?: IEditorMinimapOptions;
/**
* Control the behavior of the find widget.
*/
find?: IEditorFindOptions;
/** /**
* Display overflow widgets as `fixed`. * Display overflow widgets as `fixed`.
* Defaults to `false`. * Defaults to `false`.
...@@ -3153,6 +3164,10 @@ declare module monaco.editor { ...@@ -3153,6 +3164,10 @@ declare module monaco.editor {
readonly maxColumn: number; readonly maxColumn: number;
} }
export interface InternalEditorFindOptions {
readonly seedSearchStringFromSelection: boolean;
}
export interface EditorWrappingInfo { export interface EditorWrappingInfo {
readonly inDiffEditor: boolean; readonly inDiffEditor: boolean;
readonly isDominatedByLongLines: boolean; readonly isDominatedByLongLines: boolean;
...@@ -3223,6 +3238,7 @@ declare module monaco.editor { ...@@ -3223,6 +3238,7 @@ declare module monaco.editor {
readonly folding: boolean; readonly folding: boolean;
readonly showFoldingControls: 'always' | 'mouseover'; readonly showFoldingControls: 'always' | 'mouseover';
readonly matchBrackets: boolean; readonly matchBrackets: boolean;
readonly find: InternalEditorFindOptions;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册