1
0
Fork 0
mirror of https://we.phorge.it/source/phorge.git synced 2024-11-10 08:52:39 +01:00

Make "Reply" on ghost inlines work correctly (or, at least, consistently)

Summary:
Ref T7447. Ref T7870. When you "reply" to a ghost inline, make it work properly.

This exact behavior is arguable. In particular, when you reply to a ghost inline, we //could// put the reply on the same diff as the original.

I suspect it aligns better with user exepectation to put the new inline on the current (visible) diff instead, and generally for inlines to flow forward through time and all of the ghosts to pretty much be older than all of the non-ghosts in most cases. We can see how it feels and adjust things if this turns out to not make sense.

Test Plan:
  - Replied to ghost inlines, got new inlines on the proper display line.
  - Replied to normal inlines, got normal behavior.
  - Made some new inlines.

Reviewers: btrahan

Reviewed By: btrahan

Subscribers: epriestley

Maniphest Tasks: T7870, T7447

Differential Revision: https://secure.phabricator.com/D12492
This commit is contained in:
epriestley 2015-04-21 07:28:02 -07:00
parent 84f62bdf9a
commit c596c358db

View file

@ -206,21 +206,21 @@ abstract class PhabricatorInlineCommentController
$edit_dialog = $this->buildEditDialog();
if ($this->getOperation() == 'reply') {
$inline = $this->loadComment($this->getCommentID());
$edit_dialog->setTitle(pht('Reply to Inline Comment'));
$changeset = $inline->getChangesetID();
$is_new = $inline->getIsNewFile();
$number = $inline->getLineNumber();
$length = $inline->getLineLength();
} else {
$edit_dialog->setTitle(pht('New Inline Comment'));
$changeset = $this->getChangesetID();
$is_new = $this->getIsNewFile();
$number = $this->getLineNumber();
$length = $this->getLineLength();
}
// NOTE: We read the values from the client (the display values), not
// the values from the database (the original values) when replying.
// In particular, when replying to a ghost comment which was moved
// across diffs and then moved backward to the most recent visible
// line, we want to reply on the display line (which exists), not on
// the comment's original line (which may not exist in this changeset).
$is_new = $this->getIsNewFile();
$number = $this->getLineNumber();
$length = $this->getLineLength();
$edit_dialog->addHiddenInput('op', 'create');
$edit_dialog->addHiddenInput('is_new', $is_new);
$edit_dialog->addHiddenInput('number', $number);
@ -261,14 +261,11 @@ abstract class PhabricatorInlineCommentController
pht('Failed to load comment "%s".', $reply_phid));
}
if ($reply_comment->getChangesetID() != $this->getChangesetID()) {
throw new Exception(
pht(
'Comment "%s" belongs to wrong changeset (%s vs %s).',
$reply_phid,
$reply_comment->getChangesetID(),
$this->getChangesetID()));
}
// NOTE: It's fine to reply to a comment from a different changeset, so
// the reply comment may not appear on the same changeset that the new
// comment appears on. This is expected in the case of ghost comments.
// We currently put the new comment on the visible changeset, not the
// original comment's changeset.
}
}