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

Commit

Permalink
Code review: cleaner way to check for inline editors, hoist out a const,
Browse files Browse the repository at this point in the history
tweak comments, narrower tickmarks on Mac (per Larz), go back to window.*
references in Async.
  • Loading branch information
peterflynn committed Sep 15, 2013
1 parent 293ef35 commit 859119f
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 10 deletions.
5 changes: 5 additions & 0 deletions src/editor/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -506,6 +506,11 @@ define(function (require, exports, module) {
});
};

/** @return {boolean} True if editor is not showing the entire text of the document (i.e. an inline editor) */
Editor.prototype.isTextSubset = function () {
return Boolean(this._visibleRange);
};

/**
* Ensures that the lines that are actually hidden in the inline editor correspond to
* the desired visible range.
Expand Down
2 changes: 1 addition & 1 deletion src/search/FindReplace.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ define(function (require, exports, module) {
// Clear highlights but leave search state in place so Find Next/Previous work after closing
clearHighlights(cm, state);

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

Expand Down
9 changes: 6 additions & 3 deletions src/search/ScrollTrackMarkers.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,9 @@ define(function (require, exports, module) {
Async = require("utils/Async");


/** @const @type {number} Height (and width) or scrollbar up/down arrow button on Win */
var WIN_ARROW_HT = 17;

/** @type {?Editor} Editor the markers are currently shown for, or null if not shown */
var editor;

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

} else {
Expand Down Expand Up @@ -109,7 +112,7 @@ define(function (require, exports, module) {
editor = curEditor;

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

Expand Down
1 change: 1 addition & 0 deletions src/styles/brackets.less
Original file line number Diff line number Diff line change
Expand Up @@ -938,6 +938,7 @@ a, img {
.tickmark {
position: absolute;
width: 16px;
body.platform-mac & { width: 15px; }

height: 1px;
background-color: #eddd23;
Expand Down
13 changes: 7 additions & 6 deletions src/utils/Async.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@


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

/**
* Utilities for working with Deferred, Promise, and other asynchronous processes.
Expand Down Expand Up @@ -225,7 +225,7 @@ define(function (require, exports, module) {
// if we've exhausted our maxBlockingTime
if ((new Date()).getTime() - sliceStartTime >= maxBlockingTime) {
//yield
setTimeout(function () {
window.setTimeout(function () {
sliceStartTime = (new Date()).getTime();
result.resolve();
}, idleTime);
Expand Down Expand Up @@ -301,11 +301,11 @@ define(function (require, exports, module) {
function withTimeout(promise, timeout) {
var wrapper = new $.Deferred();

var timer = setTimeout(function () {
var timer = window.setTimeout(function () {
wrapper.reject(ERROR_TIMEOUT);
}, timeout);
promise.always(function () {
clearTimeout(timer);
window.clearTimeout(timer);
});

// If the wrapper was already rejected due to timeout, the Promise's calls to resolve/reject
Expand Down Expand Up @@ -429,14 +429,15 @@ define(function (require, exports, module) {
*
* @param {number} idleDelay Minimum delay (ms) before invoking callback.
* @param {!function()} callback
* @return {!function()}
*/
function whenIdle(idleDelay, callback) {
var timer;
return function () {
if (timer) {
clearTimeout(timer);
window.clearTimeout(timer);
}
timer = setTimeout(function () {
timer = window.setTimeout(function () {
timer = null;
callback();
}, idleDelay);
Expand Down

0 comments on commit 859119f

Please sign in to comment.