提交 2513c1b0 编写于 作者: R rebornix

Fix #15148. Auto find in selection.

上级 066db6b8
......@@ -262,6 +262,11 @@ const editorConfiguration: IConfigurationNode = {
'default': EDITOR_DEFAULTS.contribInfo.find.seedSearchStringFromSelection,
'description': nls.localize('find.seedSearchStringFromSelection', "Controls if we seed the search string in Find Widget from editor selection")
},
'editor.find.autoFindInSelection': {
'type': 'boolean',
'default': EDITOR_DEFAULTS.contribInfo.find.autoFindInSelection,
'description': nls.localize('find.autoFindInSelection', "Controls if Find in Selection flag is turned on when multiple characters or lines of text are selected in the editor")
},
'editor.wordWrap': {
'type': 'string',
'enum': ['off', 'on', 'wordWrapColumn', 'bounded'],
......
......@@ -78,7 +78,14 @@ export interface IEditorScrollbarOptions {
* Configuration options for editor find widget
*/
export interface IEditorFindOptions {
/**
* Controls if we seed search string in the Find Widget with editor selection.
*/
seedSearchStringFromSelection?: boolean;
/**
* Controls if Find in Selection flag is turned on when multiple lines of text are selected in the editor.
*/
autoFindInSelection: boolean;
}
/**
......@@ -685,6 +692,7 @@ export interface InternalEditorMinimapOptions {
export interface InternalEditorFindOptions {
readonly seedSearchStringFromSelection: boolean;
readonly autoFindInSelection: boolean;
}
export interface EditorWrappingInfo {
......@@ -1027,6 +1035,7 @@ export class InternalEditorOptions {
private static _equalFindOptions(a: InternalEditorFindOptions, b: InternalEditorFindOptions): boolean {
return (
a.seedSearchStringFromSelection === b.seedSearchStringFromSelection
&& a.autoFindInSelection === b.autoFindInSelection
);
}
......@@ -1446,7 +1455,8 @@ export class EditorOptionsValidator {
}
return {
seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection)
seedSearchStringFromSelection: _boolean(opts.seedSearchStringFromSelection, defaults.seedSearchStringFromSelection),
autoFindInSelection: _boolean(opts.autoFindInSelection, defaults.autoFindInSelection)
};
}
......@@ -1995,7 +2005,8 @@ export const EDITOR_DEFAULTS: IValidatedEditorOptions = {
showFoldingControls: 'mouseover',
matchBrackets: true,
find: {
seedSearchStringFromSelection: true
seedSearchStringFromSelection: true,
autoFindInSelection: false
}
},
};
......@@ -246,10 +246,8 @@ 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);
}
}
......@@ -365,6 +363,13 @@ export class FindWidget extends Widget implements IOverlayWidget {
if (!this._isVisible) {
this._isVisible = true;
let selection = this._codeEditor.getSelection();
let isSelection = selection ? (selection.startLineNumber !== selection.endLineNumber || selection.startColumn !== selection.endColumn) : false;
if (isSelection && this._codeEditor.getConfiguration().contribInfo.find.autoFindInSelection) {
this._toggleSelectionFind.checked = true;
} else {
this._toggleSelectionFind.checked = false;
}
this._updateButtons();
setTimeout(() => {
......
......@@ -2631,7 +2631,14 @@ declare module monaco.editor {
* Configuration options for editor find widget
*/
export interface IEditorFindOptions {
/**
* Controls if we seed search string in the Find Widget with editor selection.
*/
seedSearchStringFromSelection?: boolean;
/**
* Controls if Find in Selection flag is turned on when multiple characters or lines of text are selected in the editor.
*/
autoFindInSelection: boolean;
}
/**
......@@ -3166,6 +3173,7 @@ declare module monaco.editor {
export interface InternalEditorFindOptions {
readonly seedSearchStringFromSelection: boolean;
readonly autoFindInSelection: boolean;
}
export interface EditorWrappingInfo {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册