Skip to content
This repository was archived by the owner on Sep 6, 2021. It is now read-only.

Commit 5c420ac

Browse files
committed
Merge pull request #7042 from adobe/nj/issue-7040
Use state of case sensitivity toggle even when find bar isn't open
2 parents 8250821 + 7b1f77d commit 5c420ac

2 files changed

Lines changed: 62 additions & 2 deletions

File tree

src/search/FindReplace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ define(function (require, exports, module) {
100100

101101
function getSearchCursor(cm, query, pos) {
102102
// Heuristic: if the query string is all lowercase, do a case insensitive search.
103-
return cm.getSearchCursor(query, pos, !$("#find-case-sensitive").is(".active"));
103+
return cm.getSearchCursor(query, pos, !PreferencesManager.getViewState("caseSensitive"));
104104
}
105105

106106
function _updateSearchBarFromPrefs() {

test/spec/FindReplace-test.js

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,16 @@ define(function (require, exports, module) {
107107
}
108108
expect(actualHighlights.length).toEqual(expectedDOMHighlightCount);
109109
}
110+
function expectFindNextSelections(selections) {
111+
var i;
112+
for (i = 0; i < selections.length; i++) {
113+
expectSelection(selections[i]);
114+
twCommandManager.execute(Commands.EDIT_FIND_NEXT);
115+
}
116+
117+
// next find should wraparound
118+
expectSelection(selections[0]);
119+
}
110120

111121

112122
function getSearchBar() {
@@ -407,6 +417,25 @@ define(function (require, exports, module) {
407417
});
408418
});
409419

420+
it("should Find Next after search bar closed, remembering case sensitivity state", function () {
421+
runs(function () {
422+
myEditor.setCursorPos(0, 0);
423+
424+
twCommandManager.execute(Commands.EDIT_FIND);
425+
426+
toggleCaseSensitive(true);
427+
enterSearchText("Foo");
428+
pressEscape();
429+
expectHighlightedMatches([]);
430+
});
431+
432+
waitsForSearchBarClose();
433+
434+
runs(function () {
435+
expectFindNextSelections(capitalFooSelections);
436+
});
437+
});
438+
410439
it("shouldn't Find Next after search bar reopened", function () {
411440
runs(function () {
412441
myEditor.setCursorPos(0, 0);
@@ -668,6 +697,37 @@ define(function (require, exports, module) {
668697
expectSelection(expectedSelections[0]);
669698
});
670699

700+
701+
it("should Find Next after search bar closed, remembering last used regexp", function () {
702+
var expectedSelections = [
703+
{start: {line: LINE_FIRST_REQUIRE + 1, ch: 8}, end: {line: LINE_FIRST_REQUIRE + 1, ch: 11}},
704+
{start: {line: LINE_FIRST_REQUIRE + 1, ch: 31}, end: {line: LINE_FIRST_REQUIRE + 1, ch: 34}},
705+
{start: {line: LINE_FIRST_REQUIRE + 2, ch: 8}, end: {line: LINE_FIRST_REQUIRE + 2, ch: 11}},
706+
{start: {line: LINE_FIRST_REQUIRE + 2, ch: 31}, end: {line: LINE_FIRST_REQUIRE + 2, ch: 34}}
707+
];
708+
709+
runs(function () {
710+
myEditor.setCursorPos(0, 0);
711+
712+
twCommandManager.execute(Commands.EDIT_FIND);
713+
714+
toggleRegexp(true);
715+
enterSearchText("Ba.");
716+
pressEscape();
717+
expectHighlightedMatches([]);
718+
});
719+
720+
waitsForSearchBarClose();
721+
722+
runs(function () {
723+
expectFindNextSelections(expectedSelections);
724+
725+
// explicitly clean up since we closed the search bar
726+
twCommandManager.execute(Commands.EDIT_FIND);
727+
toggleRegexp(false);
728+
});
729+
});
730+
671731
it("toggling regexp option should update results immediately", function () {
672732
myEditor.setCursorPos(0, 0);
673733

@@ -718,7 +778,7 @@ define(function (require, exports, module) {
718778
expectHighlightedMatches(expectedSelections);
719779
expectSelection(expectedSelections[0]);
720780
});
721-
781+
722782
it("shouldn't choke on invalid regexp", function () {
723783
myEditor.setCursorPos(0, 0);
724784

0 commit comments

Comments
 (0)