Skip to content

Commit 487fc6f

Browse files
committed
chore: shorten comments in live preview caret highlight
1 parent 06d6aec commit 487fc6f

2 files changed

Lines changed: 8 additions & 14 deletions

File tree

‎src/LiveDevelopment/MultiBrowserImpl/documents/LiveDocument.js‎

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -182,20 +182,15 @@ define(function (require, exports, module) {
182182
let _selectionHolder = null;
183183

184184
/**
185-
* Lets something outside the live documents hold the preview selection, such as a
186-
* panel with a pick of its own. The caret highlights and scrolls to what it points
187-
* at the same as ever, but the held element stays the selected one.
188-
* @param {?function(LiveDocument): boolean} holder Returns true while it holds the selection; null removes it.
185+
* While the holder returns true the caret still highlights in the preview but never
186+
* selects, so a selection made elsewhere (the layers panel) stays.
187+
* @param {?function(LiveDocument): boolean} holder null removes it.
189188
*/
190189
LiveDocument.setSelectionHolder = function (holder) {
191190
_selectionHolder = holder || null;
192191
};
193192

194-
/**
195-
* How long the caret rests before the preview highlight follows it. Anything else
196-
* following the caret waits the same, or a held arrow key moves one and not the other.
197-
* @const {number}
198-
*/
193+
// for anything else that follows the caret and must settle on the same clock
199194
LiveDocument.CURSOR_HIGHLIGHT_DEBOUNCE_MS = CURSOR_HIGHLIGHT_DEBOUNCE_MS;
200195

201196
function _isSelectionHeld(liveDoc) {
@@ -356,8 +351,8 @@ define(function (require, exports, module) {
356351
*/
357352
LiveDocument.prototype.highlightRule = function (name) {
358353
const keepSelection = _isSelectionHeld(this);
359-
// Around a held selection the same rule draws differently, so it is not the same highlight.
360-
const highlight = (keepSelection ? HELD_HIGHLIGHT_PREFIX : "") + name;
354+
// the same rule draws differently around a held selection
355+
const highlight =(keepSelection ? HELD_HIGHLIGHT_PREFIX : "") + name;
361356
if (this._lastHighlight === highlight) {
362357
return;
363358
}

‎src/LiveDevelopment/MultiBrowserImpl/protocol/LiveDevProtocol.js‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -403,9 +403,8 @@ define(function (require, exports, module) {
403403
}
404404
editMode && liveDoc && liveDoc.disableHighlightOnCursorActivity(false);
405405
// the caret did not move for a script-added element, re-highlighting would drop its selection.
406-
// Nor did it move in the page's own code while another file is in front, where the
407-
// caret left behind would take the selection from the element just clicked.
408-
if (liveDoc && !msg.sourceless && _isInFront(liveDoc)) {
406+
// Nor did it move in the html while another file is in front: that stale caret would take it.
407+
if (liveDoc &&!msg.sourceless && _isInFront(liveDoc)) {
409408
liveDoc.updateHighlight();
410409
}
411410
} else {

0 commit comments

Comments
 (0)