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

Fix #20768. seedSearchStringFromSelection is now an option.

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