@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 offset/range inline behavior for rich diffs and unified diffs

Summary:
Ref T13513. The way I'm highlighting lines won't work for Jupyter notebooks or other complex content blocks, and I don't see an obvious way to make it work that's reasonably robust.

However, we can just ignore the range behavior for complex content and treat the entire block as selected. This isn't quite as fancy as the source behavior, but pretty good.

Also, adjust unified diff behavior to work correctly with highlighting and range selection.

Test Plan:
- Used range selection in a Jupyter notebook, got reasonable behavior (range is treated as "entire block").
- Used range selection in a unified diff, got equivalent behavior to 2-up diffs.

Maniphest Tasks: T13513

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

+55 -15
+8 -8
resources/celerity/map.php
··· 13 13 'core.pkg.js' => '845355f4', 14 14 'dark-console.pkg.js' => '187792c2', 15 15 'differential.pkg.css' => '319dca29', 16 - 'differential.pkg.js' => 'ccf7bdca', 16 + 'differential.pkg.js' => '695827fc', 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' => 'bfdae878', 383 - 'rsrc/js/application/diff/DiffChangesetList.js' => 'a00bf62d', 383 + 'rsrc/js/application/diff/DiffChangesetList.js' => 'b1b8500b', 384 384 'rsrc/js/application/diff/DiffInline.js' => 'b00168c1', 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' => 'bfdae878', 778 - 'phabricator-diff-changeset-list' => 'a00bf62d', 778 + 'phabricator-diff-changeset-list' => 'b1b8500b', 779 779 'phabricator-diff-inline' => 'b00168c1', 780 780 'phabricator-diff-path-view' => '8207abf9', 781 781 'phabricator-diff-tree-view' => '5d83623b', ··· 1808 1808 'javelin-util', 1809 1809 'phabricator-keyboard-shortcut', 1810 1810 ), 1811 - 'a00bf62d' => array( 1812 - 'javelin-install', 1813 - 'phuix-button-view', 1814 - 'phabricator-diff-tree-view', 1815 - ), 1816 1811 'a17b84f1' => array( 1817 1812 'javelin-behavior', 1818 1813 'javelin-dom', ··· 1931 1926 'javelin-behavior', 1932 1927 'javelin-stratcom', 1933 1928 'javelin-dom', 1929 + ), 1930 + 'b1b8500b' => array( 1931 + 'javelin-install', 1932 + 'phuix-button-view', 1933 + 'phabricator-diff-tree-view', 1934 1934 ), 1935 1935 'b26a41e4' => array( 1936 1936 'javelin-behavior',
+11 -1
src/applications/differential/render/DifferentialChangesetOneUpRenderer.php
··· 45 45 'span', 46 46 array( 47 47 'aural' => true, 48 + 'data-aural' => true, 48 49 ), 49 50 '- '); 50 51 ··· 52 53 'span', 53 54 array( 54 55 'aural' => true, 56 + 'data-aural' => true, 55 57 ), 56 58 '+ '); 57 59 ··· 171 173 } 172 174 173 175 $cells[] = $no_copy; 174 - $cells[] = phutil_tag('td', array('class' => $class), $render); 176 + 177 + $cells[] = phutil_tag( 178 + 'td', 179 + array( 180 + 'class' => $class, 181 + 'data-copy-mode' => 'copy-unified', 182 + ), 183 + $render); 184 + 175 185 $cells[] = $no_coverage; 176 186 } 177 187
+36 -6
webroot/rsrc/js/application/diff/DiffChangesetList.js
··· 441 441 442 442 this._setSourceSelection(null, null); 443 443 444 - var config = { 445 - startOffset: start.offset, 446 - endOffset: end.offset 447 - }; 448 - 449 444 var changeset = start.changeset; 445 + 446 + var config = {}; 447 + if (changeset.getResponseDocumentEngineKey() === null) { 448 + // If the changeset is using a document renderer, we ignore the 449 + // selection range and just treat this as a comment from the first 450 + // block to the last block. 451 + 452 + // If we don't discard the range, we later render a bogus highlight 453 + // if the block content is complex (like a Jupyter notebook cell 454 + // with images). 455 + 456 + config.startOffset = start.offset; 457 + config.endOffset = end.offset; 458 + } 459 + 450 460 changeset.newInlineForRange(start.targetNode, end.targetNode, config); 451 461 }, 452 462 ··· 2623 2633 td = cells[cells.length - 1]; 2624 2634 is_end = true; 2625 2635 } else { 2626 - td = JX.DOM.findAbove(fragment, 'td'); 2636 + td = this._findContentCell(fragment); 2627 2637 is_end = false; 2628 2638 } 2629 2639 ··· 2707 2717 }, 2708 2718 2709 2719 _getSelectionOffset: function(node, target) { 2720 + // If this is an aural hint node in a unified diff, ignore it when 2721 + // calculating the selection offset. 2722 + if (node.getAttribute && node.getAttribute('data-aural')) { 2723 + return { 2724 + offset: 0, 2725 + content: '', 2726 + found: false 2727 + }; 2728 + } 2729 + 2710 2730 if (!node.childNodes || !node.childNodes.length) { 2711 2731 return { 2712 2732 offset: node.textContent.length, ··· 2764 2784 2765 2785 _isContentCell: function(node) { 2766 2786 return !!node.getAttribute('data-copy-mode'); 2787 + }, 2788 + 2789 + _findContentCell: function(node) { 2790 + var cursor = node; 2791 + while (true) { 2792 + cursor = JX.DOM.findAbove(cursor, 'td'); 2793 + if (this._isContentCell(cursor)) { 2794 + return cursor; 2795 + } 2796 + } 2767 2797 } 2768 2798 2769 2799 }