Merge pull request #109767 from microsoft/rebornix/revertFix#47400
revert fix#47400
This commit is contained in:
commit
49696e87c6
2 changed files with 18 additions and 27 deletions
|
@ -30,18 +30,14 @@ import { IStorageKeysSyncRegistryService } from 'vs/platform/userDataSync/common
|
|||
|
||||
const SEARCH_STRING_MAX_LENGTH = 524288;
|
||||
|
||||
export function getSelectionSearchString(editor: ICodeEditor, seedSearchStringFromSelection: 'single' | 'multiple' = 'single'): string | null {
|
||||
export function getSelectionSearchString(editor: ICodeEditor): string | null {
|
||||
if (!editor.hasModel()) {
|
||||
return null;
|
||||
}
|
||||
|
||||
const selection = editor.getSelection();
|
||||
// if selection spans multiple lines, default search string to empty
|
||||
|
||||
if (
|
||||
(seedSearchStringFromSelection === 'single' && selection.startLineNumber === selection.endLineNumber)
|
||||
|| seedSearchStringFromSelection === 'multiple'
|
||||
) {
|
||||
if (selection.startLineNumber === selection.endLineNumber) {
|
||||
if (selection.isEmpty()) {
|
||||
const wordAtPosition = editor.getConfiguredWordAtPosition(selection.getStartPosition());
|
||||
if (wordAtPosition) {
|
||||
|
@ -65,7 +61,7 @@ export const enum FindStartFocusAction {
|
|||
|
||||
export interface IFindStartOptions {
|
||||
forceRevealReplace: boolean;
|
||||
seedSearchStringFromSelection: 'none' | 'single' | 'multiple';
|
||||
seedSearchStringFromSelection: boolean;
|
||||
seedSearchStringFromGlobalClipboard: boolean;
|
||||
shouldFocus: FindStartFocusAction;
|
||||
shouldAnimate: boolean;
|
||||
|
@ -126,7 +122,7 @@ export class CommonFindController extends Disposable implements IEditorContribut
|
|||
if (shouldRestartFind) {
|
||||
this._start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: 'none',
|
||||
seedSearchStringFromSelection: false && this._editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: false,
|
||||
|
@ -282,8 +278,8 @@ export class CommonFindController extends Disposable implements IEditorContribut
|
|||
isRevealed: true
|
||||
};
|
||||
|
||||
if (opts.seedSearchStringFromSelection === 'single') {
|
||||
let selectionSearchString = getSelectionSearchString(this._editor, opts.seedSearchStringFromSelection);
|
||||
if (opts.seedSearchStringFromSelection) {
|
||||
let selectionSearchString = getSelectionSearchString(this._editor);
|
||||
if (selectionSearchString) {
|
||||
if (this._state.isRegex) {
|
||||
stateChanges.searchString = strings.escapeRegExpCharacters(selectionSearchString);
|
||||
|
@ -291,11 +287,6 @@ export class CommonFindController extends Disposable implements IEditorContribut
|
|||
stateChanges.searchString = selectionSearchString;
|
||||
}
|
||||
}
|
||||
} else if (opts.seedSearchStringFromSelection === 'multiple' && !opts.updateSearchScope) {
|
||||
let selectionSearchString = getSelectionSearchString(this._editor, opts.seedSearchStringFromSelection);
|
||||
if (selectionSearchString) {
|
||||
stateChanges.searchString = selectionSearchString;
|
||||
}
|
||||
}
|
||||
|
||||
if (!stateChanges.searchString && opts.seedSearchStringFromGlobalClipboard) {
|
||||
|
@ -502,7 +493,7 @@ export class StartFindAction extends MultiEditorAction {
|
|||
if (controller) {
|
||||
await controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection ? 'single' : 'none',
|
||||
seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getOption(EditorOption.find).globalFindClipboard,
|
||||
shouldFocus: FindStartFocusAction.FocusFindInput,
|
||||
shouldAnimate: true,
|
||||
|
@ -537,7 +528,7 @@ export class StartFindWithSelectionAction extends EditorAction {
|
|||
if (controller) {
|
||||
await controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: 'multiple',
|
||||
seedSearchStringFromSelection: true,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: true,
|
||||
|
@ -555,7 +546,7 @@ export abstract class MatchFindAction extends EditorAction {
|
|||
if (controller && !this._run(controller)) {
|
||||
await controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: (controller.getState().searchString.length === 0) && editor.getOption(EditorOption.find).seedSearchStringFromSelection ? 'single' : 'multiple',
|
||||
seedSearchStringFromSelection: (controller.getState().searchString.length === 0) && editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: true,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: true,
|
||||
|
@ -668,7 +659,7 @@ export abstract class SelectionMatchFindAction extends EditorAction {
|
|||
if (!this._run(controller)) {
|
||||
await controller.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection ? 'single' : 'none',
|
||||
seedSearchStringFromSelection: editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: true,
|
||||
|
@ -774,7 +765,7 @@ export class StartFindReplaceAction extends MultiEditorAction {
|
|||
if (controller) {
|
||||
await controller.start({
|
||||
forceRevealReplace: true,
|
||||
seedSearchStringFromSelection: seedSearchStringFromSelection ? 'single' : 'none',
|
||||
seedSearchStringFromSelection: seedSearchStringFromSelection,
|
||||
seedSearchStringFromGlobalClipboard: editor.getOption(EditorOption.find).seedSearchStringFromSelection,
|
||||
shouldFocus: shouldFocus,
|
||||
shouldAnimate: true,
|
||||
|
|
|
@ -272,7 +272,7 @@ suite('FindController', async () => {
|
|||
findController.setSearchString(testRegexString);
|
||||
await findController.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: 'none',
|
||||
seedSearchStringFromSelection: false,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.FocusFindInput,
|
||||
shouldAnimate: false,
|
||||
|
@ -298,7 +298,7 @@ suite('FindController', async () => {
|
|||
let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);
|
||||
await findController.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: 'none',
|
||||
seedSearchStringFromSelection: false,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: false,
|
||||
|
@ -524,9 +524,9 @@ suite('FindController query options persistence', async () => {
|
|||
], { serviceCollection: serviceCollection, find: { autoFindInSelection: 'always', globalFindClipboard: false } }, async (editor) => {
|
||||
// clipboardState = '';
|
||||
let findController = editor.registerAndInstantiateContribution(TestFindController.ID, TestFindController);
|
||||
const findConfig: IFindStartOptions = {
|
||||
const findConfig = {
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: 'none',
|
||||
seedSearchStringFromSelection: false,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: false,
|
||||
|
@ -558,7 +558,7 @@ suite('FindController query options persistence', async () => {
|
|||
|
||||
await findController.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: 'none',
|
||||
seedSearchStringFromSelection: false,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: false,
|
||||
|
@ -582,7 +582,7 @@ suite('FindController query options persistence', async () => {
|
|||
|
||||
await findController.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: 'none',
|
||||
seedSearchStringFromSelection: false,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: false,
|
||||
|
@ -607,7 +607,7 @@ suite('FindController query options persistence', async () => {
|
|||
|
||||
await findController.start({
|
||||
forceRevealReplace: false,
|
||||
seedSearchStringFromSelection: 'none',
|
||||
seedSearchStringFromSelection: false,
|
||||
seedSearchStringFromGlobalClipboard: false,
|
||||
shouldFocus: FindStartFocusAction.NoFocusChange,
|
||||
shouldAnimate: false,
|
||||
|
|
Loading…
Reference in a new issue