@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve select-to-comment behavior in Firefox and on unified diffs

Summary:
Ref T13513.

- Firefox represents multiple selected rows as a discontinuous range. Accommodate this.
- Unified diffs don't have a "copy" marker. Do something sort-of-reasonable for them.

Test Plan:
- Selected multiple lines of content in Firefox, got an option to add a comment.
- Selected content in unified mode, got an option to add a comment.

Maniphest Tasks: T13513

Differential Revision: https://secure.phabricator.com/D21249

+54 -30
+8 -8
resources/celerity/map.php
··· 13 13 'core.pkg.js' => '0efaf0ac', 14 14 'dark-console.pkg.js' => '187792c2', 15 15 'differential.pkg.css' => 'd71d4531', 16 - 'differential.pkg.js' => '06a7949c', 16 + 'differential.pkg.js' => 'ac6914bb', 17 17 'diffusion.pkg.css' => '42c75c37', 18 18 'diffusion.pkg.js' => 'a98c0bf7', 19 19 'maniphest.pkg.css' => '35995d6d', ··· 380 380 'rsrc/js/application/dashboard/behavior-dashboard-query-panel-select.js' => '1e413dc9', 381 381 'rsrc/js/application/dashboard/behavior-dashboard-tab-panel.js' => '0116d3e8', 382 382 'rsrc/js/application/diff/DiffChangeset.js' => '20715b98', 383 - 'rsrc/js/application/diff/DiffChangesetList.js' => '4a3639a1', 383 + 'rsrc/js/application/diff/DiffChangesetList.js' => '9d5b137e', 384 384 'rsrc/js/application/diff/DiffInline.js' => '6227a0e3', 385 385 'rsrc/js/application/diff/DiffPathView.js' => '8207abf9', 386 386 'rsrc/js/application/diff/DiffTreeView.js' => '5d83623b', ··· 775 775 'phabricator-darkmessage' => '26cd4b73', 776 776 'phabricator-dashboard-css' => '5a205b9d', 777 777 'phabricator-diff-changeset' => '20715b98', 778 - 'phabricator-diff-changeset-list' => '4a3639a1', 778 + 'phabricator-diff-changeset-list' => '9d5b137e', 779 779 'phabricator-diff-inline' => '6227a0e3', 780 780 'phabricator-diff-path-view' => '8207abf9', 781 781 'phabricator-diff-tree-view' => '5d83623b', ··· 1327 1327 '490e2e2e' => array( 1328 1328 'phui-oi-list-view-css', 1329 1329 ), 1330 - '4a3639a1' => array( 1331 - 'javelin-install', 1332 - 'phuix-button-view', 1333 - 'phabricator-diff-tree-view', 1334 - ), 1335 1330 '4a7fb02b' => array( 1336 1331 'javelin-behavior', 1337 1332 'javelin-dom', ··· 1820 1815 'javelin-dom', 1821 1816 'javelin-uri', 1822 1817 'phabricator-textareautils', 1818 + ), 1819 + '9d5b137e' => array( 1820 + 'javelin-install', 1821 + 'phuix-button-view', 1822 + 'phabricator-diff-tree-view', 1823 1823 ), 1824 1824 '9f081f05' => array( 1825 1825 'javelin-behavior',
+46 -22
webroot/rsrc/js/application/diff/DiffChangesetList.js
··· 2232 2232 _updateSourceSelection: function() { 2233 2233 var ranges = this._getSelectedRanges(); 2234 2234 2235 - // If we have zero or more than one range, don't do anything. 2236 - if (ranges.length === 1) { 2237 - for (var ii = 0; ii < ranges.length; ii++) { 2238 - var range = ranges[ii]; 2239 - 2240 - var head = range.startContainer; 2241 - var last = range.endContainer; 2235 + // In Firefox, selecting multiple rows gives us multiple ranges. In 2236 + // Safari and Chrome, we get a single range. 2237 + if (!ranges.length) { 2238 + this._setSourceSelection(null, null); 2239 + return; 2240 + } 2242 2241 2243 - var head_loc = this._getFragmentLocation(head); 2244 - var last_loc = this._getFragmentLocation(last); 2242 + var min = 0; 2243 + var max = ranges.length - 1; 2245 2244 2246 - if (head_loc === null || last_loc === null) { 2247 - break; 2248 - } 2245 + var head = ranges[min].startContainer; 2246 + var last = ranges[max].endContainer; 2249 2247 2250 - if (head_loc.changesetID !== last_loc.changesetID) { 2251 - break; 2252 - } 2248 + var head_loc = this._getFragmentLocation(head); 2249 + var last_loc = this._getFragmentLocation(last); 2253 2250 2254 - head_loc.offset += range.startOffset; 2255 - last_loc.offset += range.endOffset; 2251 + if (head_loc === null || last_loc === null) { 2252 + this._setSourceSelection(null, null); 2253 + return; 2254 + } 2256 2255 2257 - this._setSourceSelection(head_loc, last_loc); 2258 - return; 2259 - } 2256 + if (head_loc.changesetID !== last_loc.changesetID) { 2257 + this._setSourceSelection(null, null); 2258 + return; 2260 2259 } 2261 2260 2262 - this._setSourceSelection(null, null); 2261 + head_loc.offset += ranges[min].startOffset; 2262 + last_loc.offset += ranges[max].endOffset; 2263 + 2264 + this._setSourceSelection(head_loc, last_loc); 2263 2265 }, 2264 2266 2265 2267 _setSourceSelection: function(start, end) { ··· 2382 2384 // Find the line number and display column for the fragment. 2383 2385 var line = null; 2384 2386 var column_count = -1; 2387 + var has_new = false; 2388 + var has_old = false; 2385 2389 var offset = null; 2386 2390 var target_node = null; 2387 2391 var td; ··· 2415 2419 while (cursor) { 2416 2420 if (cursor.getAttribute('data-copy-mode')) { 2417 2421 column_count++; 2422 + } else { 2423 + // In unified mode, the content column isn't currently marked 2424 + // with an attribute, and we can't count content columns anyway. 2425 + // Keep track of whether or not we see a "NL" (New Line) column 2426 + // and/or an "OL" (Old Line) column to try to puzzle out which 2427 + // side of the display change we're on. 2428 + 2429 + if (cursor.id.match(/NL/)) { 2430 + has_new = true; 2431 + } else if (cursor.id.match(/OL/)) { 2432 + has_old = true; 2433 + } 2418 2434 } 2419 2435 2420 2436 var n = parseInt(cursor.getAttribute('data-n')); ··· 2434 2450 } 2435 2451 2436 2452 if (column_count < 0) { 2437 - return null; 2453 + if (has_new || has_old) { 2454 + if (has_new) { 2455 + column_count = 1; 2456 + } else { 2457 + column_count = 0; 2458 + } 2459 + } else { 2460 + return null; 2461 + } 2438 2462 } 2439 2463 2440 2464 var seen = 0;