提交 1f0afd63 编写于 作者: R rebornix

Re #27083. Find in selection should work even if the selection is a single line.

上级 f9c292f9
......@@ -179,8 +179,12 @@ export class FindModelBoundToEditorModel {
}
if (findScope !== null) {
if (findScope.startLineNumber !== findScope.endLineNumber) {
// multiline find scope => expand to line starts / ends
findScope = new Range(findScope.startLineNumber, 1, findScope.endLineNumber, this._editor.getModel().getLineMaxColumn(findScope.endLineNumber));
if (findScope.endColumn === 1) {
findScope = new Range(findScope.startLineNumber, 1, findScope.endLineNumber - 1, this._editor.getModel().getLineMaxColumn(findScope.endLineNumber - 1));
} else {
// multiline find scope => expand to line starts / ends
findScope = new Range(findScope.startLineNumber, 1, findScope.endLineNumber, this._editor.getModel().getLineMaxColumn(findScope.endLineNumber));
}
}
}
......
......@@ -610,7 +610,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
if (this._toggleSelectionFind.checked) {
let selection = this._codeEditor.getSelection();
if (selection.endColumn === 1 && selection.endLineNumber > selection.startLineNumber) {
selection = selection.setEndPosition(selection.endLineNumber - 1, 1);
selection = selection.setEndPosition(selection.endLineNumber - 1, this._codeEditor.getModel().getLineMaxColumn(selection.endLineNumber - 1));
}
let currentMatch = this._state.currentMatch;
if (selection.startLineNumber !== selection.endLineNumber) {
......@@ -806,7 +806,7 @@ export class FindWidget extends Widget implements IOverlayWidget, IHorizontalSas
if (this._toggleSelectionFind.checked) {
let selection = this._codeEditor.getSelection();
if (selection.endColumn === 1 && selection.endLineNumber > selection.startLineNumber) {
selection = selection.setEndPosition(selection.endLineNumber - 1, 1);
selection = selection.setEndPosition(selection.endLineNumber - 1, this._codeEditor.getModel().getLineMaxColumn(selection.endLineNumber - 1));
}
if (!selection.isEmpty()) {
this._state.change({ searchScope: selection }, true);
......
......@@ -2031,4 +2031,22 @@ suite('FindModel', () => {
findModel.dispose();
findState.dispose();
});
findTest('issue #27083. search scope works even if it is a single line', (editor, cursor) => {
let findState = new FindReplaceState();
findState.change({ searchString: 'hello', wholeWord: true, searchScope: new Range(7, 1, 8, 1) }, false);
let findModel = new FindModelBoundToEditorModel(editor, findState);
assertFindState(
editor,
[1, 1, 1, 1],
null,
[
[7, 14, 7, 19]
]
);
findModel.dispose();
findState.dispose();
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册