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

Commit 1acded2

Browse files
committed
When Find has no results, turn search field bg color red. Less ambiguous
than old behavior where selection disappears w/ no other feedback. Also fix indentation in search bar LESS code, and move one misplaced Dialog style to the right LESS file (with better docs).
1 parent 7e25465 commit 1acded2

3 files changed

Lines changed: 40 additions & 27 deletions

File tree

src/search/FindReplace.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ define(function (require, exports, module) {
8989
}
9090

9191
function findNext(cm, rev) {
92+
var found = true;
9293
cm.operation(function () {
9394
var state = getSearchState(cm);
9495
var cursor = getSearchCursor(cm, state.query, rev ? state.posFrom : state.posTo);
@@ -99,13 +100,15 @@ define(function (require, exports, module) {
99100
// No result found, period: clear selection & bail
100101
if (!cursor.find(rev)) {
101102
cm.setCursor(cm.getCursor()); // collapses selection, keeping cursor in place to avoid scrolling
103+
found = false;
102104
return;
103105
}
104106
}
105107
cm.setSelection(cursor.from(), cursor.to());
106108
state.posFrom = cursor.from();
107109
state.posTo = cursor.to();
108110
});
111+
return found;
109112
}
110113

111114
function clearSearch(cm) {
@@ -164,7 +167,9 @@ define(function (require, exports, module) {
164167
}
165168

166169
state.posFrom = state.posTo = searchStartPos;
167-
findNext(cm, rev);
170+
var foundAny = findNext(cm, rev);
171+
172+
getDialogTextField().toggleClass("no-results", !foundAny);
168173
});
169174
}
170175

src/styles/brackets.less

Lines changed: 29 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -711,40 +711,47 @@ ins.jstree-icon {
711711
.code-font();
712712
}
713713

714-
/* Styles for the search dialog--this is temporary, only for debugging */
714+
715+
/* Find & Replace search bars - temporary UI, to be replaced with a richer search feature later */
715716

716717
.CodeMirror-dialog {
717-
position: relative;
718-
z-index: @z-index-cm-dialog-override;
718+
position: relative;
719+
z-index: @z-index-cm-dialog-override;
719720
}
720721

721722
.CodeMirror-dialog > div {
722-
font-family: @fontstack-sans-serif;
723-
position: absolute;
724-
top: 0; left: 0; right: 0;
725-
background: @background-color-2;
726-
color: @content-color;
727-
border-bottom: 1px solid @bc-gray;
728-
.box-shadow(0 1px 3px 0 fadeout(@bc-black, 70%));
729-
z-index: 1;
730-
padding: .5em .8em;
731-
overflow: hidden;
723+
font-family: @fontstack-sans-serif;
724+
position: absolute;
725+
top: 0; left: 0; right: 0;
726+
background: @background-color-2;
727+
color: @content-color;
728+
border-bottom: 1px solid @bc-gray;
729+
.box-shadow(0 1px 3px 0 fadeout(@bc-black, 70%));
730+
z-index: 1;
731+
padding: .5em .8em;
732+
overflow: hidden;
732733
}
733734

734735
.CodeMirror-dialog input {
735-
font-family: @fontstack-sans-serif;
736-
border: 1px solid @content-color-weaker;
737-
outline: none;
738-
background: @background-color-3;
739-
width: 20em;
740-
margin: .3em .3em;
741-
color: inherit;
736+
font-family: @fontstack-sans-serif;
737+
border: 1px solid @content-color-weaker;
738+
outline: none;
739+
background: @background-color-3;
740+
width: 20em;
741+
margin: .3em .3em;
742+
color: inherit;
743+
&.no-results {
744+
background-color: mix(@background-color-3, #FF0000, 70%);
745+
}
742746
}
743747

744748
.CodeMirror-searching {
745-
background-color: inherit;
749+
background-color: inherit;
746750
}
747751

752+
753+
/* Quick Open search bar & dropdown */
754+
748755
.smart_autocomplete_container {
749756

750757
border: 1px solid #999;
@@ -772,8 +779,4 @@ ins.jstree-icon {
772779

773780
li.smart_autocomplete_highlight {
774781
background-color: #e0f0fa;
775-
}
776-
777-
.clickable-link {
778-
cursor: pointer;
779-
}
782+
}

src/styles/brackets_patterns_override.less

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -363,6 +363,11 @@
363363
font-weight: @font-weight-semibold;
364364
}
365365

366+
/* Any Dialog text in this style is automatically turned into a link that opens in the browser. Use data-href for the link's target. */
367+
.clickable-link {
368+
cursor: pointer;
369+
}
370+
366371
.btn {
367372
font-size: 16px;
368373
font-weight: @font-weight-semibold;

0 commit comments

Comments
 (0)