From cfb5de6fa77febc39ed69717449512ac5791d1dc Mon Sep 17 00:00:00 2001 From: epriestley Date: Thu, 14 May 2020 10:53:03 -0700 Subject: [PATCH] Distinguish more carefully between "null" inline offsets and "0" inline offsets Summary: Ref T13513. Currently, when creating an inline by selecting a line range, slightly careless handling leads to an inline with "0" offsets (by passing "undefined" to the server). This causes the block to highlight every line except the last one as fully bright, which is incorrect. An inline with "0" offsets and an inline with no offsets are different. Be more careful about passing offsets around and rendering them. Test Plan: - Used the line numbers to add an inline to lines 4-8 of a change. - Hovered the inline. - Saw all four lines marked as "dull"-highlighted (previously: three bright lines, one dull line). Maniphest Tasks: T13513 Differential Revision: https://secure.phabricator.com/D21252 --- resources/celerity/map.php | 26 +++++++++---------- .../js/application/diff/DiffChangesetList.js | 8 +++--- .../rsrc/js/application/diff/DiffInline.js | 5 ++-- 3 files changed, 20 insertions(+), 19 deletions(-) diff --git a/resources/celerity/map.php b/resources/celerity/map.php index 02ac5779d9..46ea82db60 100644 --- a/resources/celerity/map.php +++ b/resources/celerity/map.php @@ -13,7 +13,7 @@ return array( 'core.pkg.js' => '0efaf0ac', 'dark-console.pkg.js' => '187792c2', 'differential.pkg.css' => 'b042ee8b', - 'differential.pkg.js' => '4b2b5659', + 'differential.pkg.js' => '79dfae6e', 'diffusion.pkg.css' => '42c75c37', 'diffusion.pkg.js' => 'a98c0bf7', 'maniphest.pkg.css' => '35995d6d', @@ -380,8 +380,8 @@ return array( 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9', 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', 'rsrc/js/application/diff/DiffChangeset.js' => 'b6bb0240', - 'rsrc/js/application/diff/DiffChangesetList.js' => '2347e0a6', - 'rsrc/js/application/diff/DiffInline.js' => '417b3cdb', + 'rsrc/js/application/diff/DiffChangesetList.js' => '1e8658bb', + 'rsrc/js/application/diff/DiffInline.js' => '9bb6f2ad', 'rsrc/js/application/diff/DiffPathView.js' => '8207abf9', 'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b', 'rsrc/js/application/differential/behavior-diff-radios.js' => '925fe8cd', @@ -775,8 +775,8 @@ return array( 'phabricator-darkmessage' => '26cd4b73', 'phabricator-dashboard-css' => '5a205b9d', 'phabricator-diff-changeset' => 'b6bb0240', - 'phabricator-diff-changeset-list' => '2347e0a6', - 'phabricator-diff-inline' => '417b3cdb', + 'phabricator-diff-changeset-list' => '1e8658bb', + 'phabricator-diff-inline' => '9bb6f2ad', 'phabricator-diff-path-view' => '8207abf9', 'phabricator-diff-tree-view' => '5d83623b', 'phabricator-drag-and-drop-file-upload' => '4370900d', @@ -1069,6 +1069,11 @@ return array( 'javelin-behavior', 'javelin-dom', ), + '1e8658bb' => array( + 'javelin-install', + 'phuix-button-view', + 'phabricator-diff-tree-view', + ), '1ff278aa' => array( 'phui-button-css', ), @@ -1098,11 +1103,6 @@ return array( 'javelin-request', 'javelin-typeahead-source', ), - '2347e0a6' => array( - 'javelin-install', - 'phuix-button-view', - 'phabricator-diff-tree-view', - ), 23631304 => array( 'phui-fontkit-css', ), @@ -1251,9 +1251,6 @@ return array( 'javelin-behavior', 'javelin-uri', ), - '417b3cdb' => array( - 'javelin-dom', - ), '42c44e8b' => array( 'javelin-behavior', 'javelin-workflow', @@ -1795,6 +1792,9 @@ return array( 'javelin-install', 'javelin-util', ), + '9bb6f2ad' => array( + 'javelin-dom', + ), '9c01e364' => array( 'javelin-behavior', 'javelin-dom', diff --git a/webroot/rsrc/js/application/diff/DiffChangesetList.js b/webroot/rsrc/js/application/diff/DiffChangesetList.js index 2c48f8e427..a0b093e21e 100644 --- a/webroot/rsrc/js/application/diff/DiffChangesetList.js +++ b/webroot/rsrc/js/application/diff/DiffChangesetList.js @@ -1403,8 +1403,8 @@ JX.install('DiffChangesetList', { }, _newHoverMap: function(top, bot, content_cell, inline) { - var start = inline.getStartOffset() || 0; - var end = inline.getEndOffset() || 0; + var start = inline.getStartOffset(); + var end = inline.getEndOffset(); var head_row = JX.DOM.findAbove(top, 'tr'); var last_row = JX.DOM.findAbove(bot, 'tr'); @@ -1476,13 +1476,13 @@ JX.install('DiffChangesetList', { content = rows[ii].content; len = content.length; - if (ii === min) { + if (ii === min && (start !== null)) { offset_min = start; } else { offset_min = 0; } - if (ii === max) { + if (ii === max && (end !== null)) { offset_max = Math.min(end, len); } else { offset_max = len; diff --git a/webroot/rsrc/js/application/diff/DiffInline.js b/webroot/rsrc/js/application/diff/DiffInline.js index 5a2e1c956d..413b89c9ee 100644 --- a/webroot/rsrc/js/application/diff/DiffInline.js +++ b/webroot/rsrc/js/application/diff/DiffInline.js @@ -96,6 +96,7 @@ JX.install('DiffInline', { this._snippet = data.snippet; this._menuItems = data.menuItems; this._documentEngineKey = data.documentEngineKey; + this._startOffset = data.startOffset; this._endOffset = data.endOffset; @@ -167,8 +168,8 @@ JX.install('DiffInline', { this._isNewFile = data.isNewFile; this._changesetID = data.changesetID; this._isNew = true; - this._startOffset = data.startOffset; - this._endOffset = data.endOffset; + this._startOffset = null; + this._endOffset = null; // Insert the comment after any other comments which already appear on // the same row.