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

Commit 83db92c

Browse files
committed
Merge pull request #7748 from adobe/tom/highlight-matches
Highlight Selection Matches
2 parents 1f67371 + 704aa12 commit 83db92c

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

src/brackets.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@ define(function (require, exports, module) {
5555
require("thirdparty/CodeMirror2/addon/selection/active-line");
5656
require("thirdparty/CodeMirror2/addon/mode/multiplex");
5757
require("thirdparty/CodeMirror2/addon/mode/overlay");
58+
require("thirdparty/CodeMirror2/addon/search/match-highlighter");
5859
require("thirdparty/CodeMirror2/addon/search/searchcursor");
5960
require("thirdparty/CodeMirror2/keymap/sublime");
6061

src/editor/Editor.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ define(function (require, exports, module) {
8181
/** Editor preferences */
8282
var CLOSE_BRACKETS = "closeBrackets",
8383
CLOSE_TAGS = "closeTags",
84+
HIGHLIGHT_MATCHES = "highlightMatches",
8485
SCROLL_PAST_END = "scrollPastEnd",
8586
SHOW_LINE_NUMBERS = "showLineNumbers",
8687
SMART_INDENT = "smartIndent",
@@ -104,6 +105,7 @@ define(function (require, exports, module) {
104105
// Mappings from Brackets preferences to CodeMirror options
105106
cmOptions[CLOSE_BRACKETS] = "autoCloseBrackets";
106107
cmOptions[CLOSE_TAGS] = "autoCloseTags";
108+
cmOptions[HIGHLIGHT_MATCHES] = "highlightSelectionMatches";
107109
cmOptions[SCROLL_PAST_END] = "scrollPastEnd";
108110
cmOptions[SHOW_LINE_NUMBERS] = "lineNumbers";
109111
cmOptions[SMART_INDENT] = "smartIndent";
@@ -115,15 +117,16 @@ define(function (require, exports, module) {
115117

116118
PreferencesManager.definePreference(CLOSE_BRACKETS, "boolean", false);
117119
PreferencesManager.definePreference(CLOSE_TAGS, "Object", { whenOpening: true, whenClosing: true, indentTags: [] });
120+
PreferencesManager.definePreference(HIGHLIGHT_MATCHES, "boolean", false);
118121
PreferencesManager.definePreference(SCROLL_PAST_END, "boolean", false);
119122
PreferencesManager.definePreference(SHOW_LINE_NUMBERS, "boolean", true);
120123
PreferencesManager.definePreference(SMART_INDENT, "boolean", true);
121124
PreferencesManager.definePreference(SOFT_TABS, "boolean", true);
122-
PreferencesManager.definePreference(SPACE_UNITS, "number", DEFAULT_SPACE_UNITS, {
125+
PreferencesManager.definePreference(SPACE_UNITS, "number", DEFAULT_SPACE_UNITS, {
123126
validator: _.partialRight(ValidationUtils.isIntegerInRange, MIN_SPACE_UNITS, MAX_SPACE_UNITS)
124127
});
125128
PreferencesManager.definePreference(STYLE_ACTIVE_LINE, "boolean", false);
126-
PreferencesManager.definePreference(TAB_SIZE, "number", DEFAULT_TAB_SIZE, {
129+
PreferencesManager.definePreference(TAB_SIZE, "number", DEFAULT_TAB_SIZE, {
127130
validator: _.partialRight(ValidationUtils.isIntegerInRange, MIN_TAB_SIZE, MAX_TAB_SIZE)
128131
});
129132
PreferencesManager.definePreference(USE_TAB_CHAR, "boolean", false);
@@ -261,6 +264,7 @@ define(function (require, exports, module) {
261264
dragDrop : false,
262265
electricChars : false, // we use our own impl of this to avoid CodeMirror bugs; see _checkElectricChars()
263266
extraKeys : codeMirrorKeyMap,
267+
highlightSelectionMatches : currentOptions[HIGHLIGHT_MATCHES],
264268
indentUnit : currentOptions[USE_TAB_CHAR] ? currentOptions[TAB_SIZE] : currentOptions[SPACE_UNITS],
265269
indentWithTabs : currentOptions[USE_TAB_CHAR],
266270
lineNumbers : currentOptions[SHOW_LINE_NUMBERS],

src/styles/brackets_codemirror_override.less

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@
7171
}
7272
}
7373

74+
.CodeMirror-focused .cm-matchhighlight {
75+
border-bottom: 2px solid #78B2F2;
76+
}
77+
7478

7579
.cm-s-default {
7680
span.cm-keyword {color: @accent-keyword;}

0 commit comments

Comments
 (0)