@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.

Render inline comment suggestions as real diffs

Summary: Ref T13513. When rendering an inline suggestion for display, use highlighting and diffing.

Test Plan: {F7495053}

Maniphest Tasks: T13513

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

+98 -18
+3 -3
resources/celerity/map.php
··· 12 12 'core.pkg.css' => 'ba768cdb', 13 13 'core.pkg.js' => '845355f4', 14 14 'dark-console.pkg.js' => '187792c2', 15 - 'differential.pkg.css' => 'f924dbcf', 15 + 'differential.pkg.css' => '5c459f92', 16 16 'differential.pkg.js' => '256a327a', 17 17 'diffusion.pkg.css' => '42c75c37', 18 18 'diffusion.pkg.js' => 'a98c0bf7', ··· 65 65 'rsrc/css/application/differential/add-comment.css' => '7e5900d9', 66 66 'rsrc/css/application/differential/changeset-view.css' => '60c3d405', 67 67 'rsrc/css/application/differential/core.css' => '7300a73e', 68 - 'rsrc/css/application/differential/phui-inline-comment.css' => '4107254a', 68 + 'rsrc/css/application/differential/phui-inline-comment.css' => '9863a85e', 69 69 'rsrc/css/application/differential/revision-comment.css' => '7dbc8d1d', 70 70 'rsrc/css/application/differential/revision-history.css' => '8aa3eac5', 71 71 'rsrc/css/application/differential/revision-list.css' => '93d2df7d', ··· 854 854 'phui-icon-view-css' => '4cbc684a', 855 855 'phui-image-mask-css' => '62c7f4d2', 856 856 'phui-info-view-css' => 'a10a909b', 857 - 'phui-inline-comment-view-css' => '4107254a', 857 + 'phui-inline-comment-view-css' => '9863a85e', 858 858 'phui-invisible-character-view-css' => 'c694c4a4', 859 859 'phui-left-right-css' => '68513c34', 860 860 'phui-lightbox-css' => '4ebf22da',
+4 -1
src/applications/differential/parser/DifferentialChangesetParser.php
··· 834 834 ->setNewAttachesToNewFile($this->rightSideAttachesToNewFile) 835 835 ->setCodeCoverage($this->getCoverage()) 836 836 ->setRenderingReference($this->getRenderingReference()) 837 - ->setMarkupEngine($this->markupEngine) 838 837 ->setHandles($this->handles) 839 838 ->setOldLines($this->old) 840 839 ->setNewLines($this->new) ··· 844 843 ->setObjectOwnerPHID($this->getObjectOwnerPHID()) 845 844 ->setHighlightingDisabled($this->highlightingDisabled) 846 845 ->setDepthOnlyLines($this->getDepthOnlyLines()); 846 + 847 + if ($this->markupEngine) { 848 + $renderer->setMarkupEngine($this->markupEngine); 849 + } 847 850 848 851 list($engine, $old_ref, $new_ref) = $this->newDocumentEngine(); 849 852 if ($engine) {
+37 -2
src/applications/differential/render/DifferentialChangesetOneUpRenderer.php
··· 3 3 final class DifferentialChangesetOneUpRenderer 4 4 extends DifferentialChangesetHTMLRenderer { 5 5 6 + private $simpleMode; 7 + 8 + public function setSimpleMode($simple_mode) { 9 + $this->simpleMode = $simple_mode; 10 + return $this; 11 + } 12 + 13 + public function getSimpleMode() { 14 + return $this->simpleMode; 15 + } 16 + 6 17 public function isOneUpRenderer() { 7 18 return true; 8 19 } ··· 35 46 36 47 protected function renderPrimitives(array $primitives, $rows) { 37 48 list($left_prefix, $right_prefix) = $this->getLineIDPrefixes(); 49 + 50 + $is_simple = $this->getSimpleMode(); 38 51 39 52 $no_copy = phutil_tag('td', array('class' => 'copy')); 40 53 $no_coverage = null; ··· 185 198 $cells[] = $no_coverage; 186 199 } 187 200 201 + // In simple mode, only render the text. This is used to render 202 + // "Edit Suggestions" in inline comments. 203 + if ($is_simple) { 204 + $cells = array($cells[3]); 205 + } 206 + 188 207 $out[] = phutil_tag('tr', array(), $cells); 189 208 190 209 break; ··· 231 250 } 232 251 } 233 252 253 + $result = null; 254 + 234 255 if ($out) { 235 - return $this->wrapChangeInTable(phutil_implode_html('', $out)); 256 + if ($is_simple) { 257 + $result = $this->newSimpleTable($out); 258 + } else { 259 + $result = $this->wrapChangeInTable(phutil_implode_html('', $out)); 260 + } 236 261 } 237 262 238 - return null; 263 + return $result; 239 264 } 240 265 241 266 public function renderDocumentEngineBlocks( ··· 486 511 public function getRowScaffoldForInline(PHUIDiffInlineCommentView $view) { 487 512 return id(new PHUIDiffOneUpInlineCommentRowScaffold()) 488 513 ->addInlineView($view); 514 + } 515 + 516 + 517 + private function newSimpleTable($content) { 518 + return phutil_tag( 519 + 'table', 520 + array( 521 + 'class' => 'diff-1up-simple-table', 522 + ), 523 + $content); 489 524 } 490 525 491 526 }
+10
src/infrastructure/diff/inline/PhabricatorDiffInlineCommentContext.php
··· 3 3 final class PhabricatorDiffInlineCommentContext 4 4 extends PhabricatorInlineCommentContext { 5 5 6 + private $filename; 6 7 private $headLines; 7 8 private $bodyLines; 8 9 private $tailLines; 10 + 11 + public function setFilename($filename) { 12 + $this->filename = $filename; 13 + return $this; 14 + } 15 + 16 + public function getFilename() { 17 + return $this->filename; 18 + } 9 19 10 20 public function setHeadLines(array $head_lines) { 11 21 $this->headLines = $head_lines;
+5
src/infrastructure/diff/query/PhabricatorDiffInlineCommentQuery.php
··· 289 289 } 290 290 291 291 if ($inline->getIsNewFile()) { 292 + $vector = $changeset->getNewStatePathVector(); 293 + $filename = last($vector); 292 294 $corpus = $changeset->makeNewFile(); 293 295 } else { 296 + $vector = $changeset->getOldStatePathVector(); 297 + $filename = last($vector); 294 298 $corpus = $changeset->makeOldFile(); 295 299 } 296 300 ··· 321 325 $tail = $this->simplifyContext($tail, false); 322 326 323 327 $context = id(new PhabricatorDiffInlineCommentContext()) 328 + ->setFilename($filename) 324 329 ->setHeadLines($head) 325 330 ->setBodyLines($body) 326 331 ->setTailLines($tail);
+21 -6
src/infrastructure/diff/view/PHUIDiffInlineCommentDetailView.php
··· 540 540 return null; 541 541 } 542 542 543 + $viewer = $this->getViewer(); 543 544 544 - $raw_diff = id(new PhabricatorDifferenceEngine()) 545 - ->generateRawDiffFromFileContent($old_lines, $new_lines); 545 + $changeset = id(new PhabricatorDifferenceEngine()) 546 + ->generateChangesetFromFileContent($old_lines, $new_lines); 547 + 548 + $changeset->setFilename($context->getFilename()); 549 + 550 + // TODO: This isn't cached! 551 + 552 + $viewstate = new PhabricatorChangesetViewState(); 553 + 554 + $parser = id(new DifferentialChangesetParser()) 555 + ->setViewer($viewer) 556 + ->setViewstate($viewstate) 557 + ->setChangeset($changeset); 558 + 559 + $renderer = new DifferentialChangesetOneUpRenderer(); 560 + $renderer->setSimpleMode(true); 561 + 562 + $parser->setRenderer($renderer); 546 563 547 - $raw_diff = phutil_split_lines($raw_diff); 548 - $raw_diff = array_slice($raw_diff, 3); 549 - $raw_diff = implode('', $raw_diff); 564 + $diff_view = $parser->render(0, 0xFFFF, array()); 550 565 551 566 $view = phutil_tag( 552 567 'div', 553 568 array( 554 569 'class' => 'inline-suggestion-view PhabricatorMonospaced', 555 570 ), 556 - $raw_diff); 571 + $diff_view); 557 572 558 573 return $view; 559 574 }
+18 -6
webroot/rsrc/css/application/differential/phui-inline-comment.css
··· 476 476 border-right: 1px solid {$lightgreyborder}; 477 477 } 478 478 479 - .inline-suggestion-input-cell { 480 - padding: 8px; 479 + .inline-suggestion-table td.inline-suggestion-input-cell { 480 + padding: 8px 4px; 481 481 } 482 482 483 - .inline-suggestion-text-cell { 484 - padding: 0 8px; 483 + .inline-suggestion-table td.inline-suggestion-text-cell { 484 + /* This is attempting to align the text in the textarea with the text on 485 + the surrounding context lines. */ 486 + padding: 0 8px 0 11px; 485 487 } 486 488 487 489 .inline-suggestion-view { 488 - padding: 8px 12px; 490 + padding: 4px 0; 489 491 white-space: pre-wrap; 490 - background: {$greybackground}; 492 + background: {$lightgreybackground}; 491 493 margin: 0 -12px 8px; 492 494 border-width: 1px 0; 493 495 border-style: solid; 494 496 border-color: {$lightgreyborder}; 495 497 } 498 + 499 + .diff-1up-simple-table { 500 + width: 100%; 501 + table-layout: fixed; 502 + } 503 + 504 + .diff-1up-simple-table > tbody > tr > td { 505 + padding-left: 12px; 506 + padding-right: 12px; 507 + }