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

Commit

Permalink
Use state of case sensitivity toggle even when find bar isn't open
Browse files Browse the repository at this point in the history
  • Loading branch information
njx committed Feb 28, 2014
1 parent 70d3e5c commit d5f3022
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/search/FindReplace.js
Expand Up @@ -100,7 +100,7 @@ define(function (require, exports, module) {

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

function _updateSearchBarFromPrefs() {
Expand Down
27 changes: 27 additions & 0 deletions test/spec/FindReplace-test.js
Expand Up @@ -407,6 +407,33 @@ define(function (require, exports, module) {
});
});

it("should Find Next after search bar closed, remembering case sensitivity state", function () {
runs(function () {
myEditor.setCursorPos(0, 0);

twCommandManager.execute(Commands.EDIT_FIND);

toggleCaseSensitive(true);
enterSearchText("Foo");
pressEscape();
expectHighlightedMatches([]);
});

waitsForSearchBarClose();

runs(function () {
expectSelection(capitalFooSelections[0]);
twCommandManager.execute(Commands.EDIT_FIND_NEXT);
expectSelection(capitalFooSelections[1]);
twCommandManager.execute(Commands.EDIT_FIND_NEXT);
expectSelection(capitalFooSelections[2]);

// next find should wraparound since it should skip the lowercase "foo()"
twCommandManager.execute(Commands.EDIT_FIND_NEXT);
expectSelection(capitalFooSelections[0]);
});
});

it("shouldn't Find Next after search bar reopened", function () {
runs(function () {
myEditor.setCursorPos(0, 0);
Expand Down

0 comments on commit d5f3022

Please sign in to comment.