提交 fb2f7039 编写于 作者: R rebornix

Fix #58604. Do not update search scope when it is empty.

上级 067ed91b
......@@ -266,7 +266,10 @@ export class CommonFindController extends Disposable implements editorCommon.IEd
}
if (opts.updateSearchScope) {
stateChanges.searchScope = this._editor.getSelection();
let currentSelection = this._editor.getSelection();
if (!currentSelection.isEmpty()) {
stateChanges.searchScope = currentSelection;
}
}
this._state.change(stateChanges, false);
......
......@@ -492,4 +492,50 @@ suite('FindController query options persistence', () => {
assert.deepEqual(findController.getState().searchScope, new Selection(1, 1, 2, 1));
});
});
test('issue #58604: Do not update searchScope if it is empty', () => {
withTestCodeEditor([
'var x = (3 * 5)',
'var y = (3 * 5)',
'var z = (3 * 5)',
], { serviceCollection: serviceCollection, find: { autoFindInSelection: true, globalFindClipboard: false } }, (editor, cursor) => {
// clipboardState = '';
editor.setSelection(new Range(1, 2, 1, 2));
let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
findController.start({
forceRevealReplace: false,
seedSearchStringFromSelection: false,
seedSearchStringFromGlobalClipboard: false,
shouldFocus: FindStartFocusAction.NoFocusChange,
shouldAnimate: false,
updateSearchScope: true
});
assert.deepEqual(findController.getState().searchScope, null);
});
});
test('issue #58604: Update searchScope if it is not empty', () => {
withTestCodeEditor([
'var x = (3 * 5)',
'var y = (3 * 5)',
'var z = (3 * 5)',
], { serviceCollection: serviceCollection, find: { autoFindInSelection: true, globalFindClipboard: false } }, (editor, cursor) => {
// clipboardState = '';
editor.setSelection(new Range(1, 2, 1, 3));
let findController = editor.registerAndInstantiateContribution<TestFindController>(TestFindController);
findController.start({
forceRevealReplace: false,
seedSearchStringFromSelection: false,
seedSearchStringFromGlobalClipboard: false,
shouldFocus: FindStartFocusAction.NoFocusChange,
shouldAnimate: false,
updateSearchScope: true
});
assert.deepEqual(findController.getState().searchScope, new Selection(1, 2, 1, 3));
});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册