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

Commit 859119f

Browse files
committed
Code review: cleaner way to check for inline editors, hoist out a const,
tweak comments, narrower tickmarks on Mac (per Larz), go back to window.* references in Async.
1 parent 293ef35 commit 859119f

5 files changed

Lines changed: 20 additions & 10 deletions

File tree

src/editor/Editor.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,11 @@ define(function (require, exports, module) {
506506
});
507507
};
508508

509+
/** @return {boolean} True if editor is not showing the entire text of the document (i.e. an inline editor) */
510+
Editor.prototype.isTextSubset = function () {
511+
return Boolean(this._visibleRange);
512+
};
513+
509514
/**
510515
* Ensures that the lines that are actually hidden in the inline editor correspond to
511516
* the desired visible range.

src/search/FindReplace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ define(function (require, exports, module) {
333333
// Clear highlights but leave search state in place so Find Next/Previous work after closing
334334
clearHighlights(cm, state);
335335

336-
// As soon as focus goes back to the editor, restore normal selection color
336+
// Dispose highlighting UI (important to restore normal selection color as soon as focus goes back to the editor)
337337
toggleHighlighting(editor, false);
338338
});
339339

src/search/ScrollTrackMarkers.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,9 @@ define(function (require, exports, module) {
3838
Async = require("utils/Async");
3939

4040

41+
/** @const @type {number} Height (and width) or scrollbar up/down arrow button on Win */
42+
var WIN_ARROW_HT = 17;
43+
4144
/** @type {?Editor} Editor the markers are currently shown for, or null if not shown */
4245
var editor;
4346

@@ -61,9 +64,9 @@ define(function (require, exports, module) {
6164
if (trackHt > 0) {
6265
// Scrollbar visible: determine offset of track from top of scrollbar
6366
if (brackets.platform === "win") {
64-
trackOffset = 17; // Up arrow pushes down track
67+
trackOffset = WIN_ARROW_HT; // Up arrow pushes down track
6568
} else {
66-
trackOffset = 0; // No arrows
69+
trackOffset = 0; // No arrows
6770
}
6871

6972
} else {
@@ -109,7 +112,7 @@ define(function (require, exports, module) {
109112
editor = curEditor;
110113

111114
// Don't support inline editors yet - search inside them is pretty screwy anyway (#2110)
112-
if (editor.getFirstVisibleLine() > 0 || editor.getLastVisibleLine() < editor.lineCount() - 1) {
115+
if (editor.isTextSubset()) {
113116
return;
114117
}
115118

src/styles/brackets.less

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,6 +938,7 @@ a, img {
938938
.tickmark {
939939
position: absolute;
940940
width: 16px;
941+
body.platform-mac & { width: 15px; }
941942

942943
height: 1px;
943944
background-color: #eddd23;

src/utils/Async.js

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323

2424

2525
/*jslint vars: true, plusplus: true, devel: true, nomen: true, indent: 4, maxerr: 50 */
26-
/*global define, $, setTimeout, clearTimeout */
26+
/*global define, $, window */
2727

2828
/**
2929
* Utilities for working with Deferred, Promise, and other asynchronous processes.
@@ -225,7 +225,7 @@ define(function (require, exports, module) {
225225
// if we've exhausted our maxBlockingTime
226226
if ((new Date()).getTime() - sliceStartTime >= maxBlockingTime) {
227227
//yield
228-
setTimeout(function () {
228+
window.setTimeout(function () {
229229
sliceStartTime = (new Date()).getTime();
230230
result.resolve();
231231
}, idleTime);
@@ -301,11 +301,11 @@ define(function (require, exports, module) {
301301
function withTimeout(promise, timeout) {
302302
var wrapper = new $.Deferred();
303303

304-
var timer = setTimeout(function () {
304+
var timer = window.setTimeout(function () {
305305
wrapper.reject(ERROR_TIMEOUT);
306306
}, timeout);
307307
promise.always(function () {
308-
clearTimeout(timer);
308+
window.clearTimeout(timer);
309309
});
310310

311311
// If the wrapper was already rejected due to timeout, the Promise's calls to resolve/reject
@@ -429,14 +429,15 @@ define(function (require, exports, module) {
429429
*
430430
* @param {number} idleDelay Minimum delay (ms) before invoking callback.
431431
* @param {!function()} callback
432+
* @return {!function()}
432433
*/
433434
function whenIdle(idleDelay, callback) {
434435
var timer;
435436
return function () {
436437
if (timer) {
437-
clearTimeout(timer);
438+
window.clearTimeout(timer);
438439
}
439-
timer = setTimeout(function () {
440+
timer = window.setTimeout(function () {
440441
timer = null;
441442
callback();
442443
}, idleDelay);

0 commit comments

Comments
 (0)