mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-26 00:32:41 +01:00
Restore the caret pointer ("^") for lint lines which only have a character offset
Summary: Ref T9846. This was dropped when I refactored how things are rendered; restore it. Test Plan: Added unit tests. Reviewers: chad Reviewed By: chad Maniphest Tasks: T9846 Differential Revision: https://secure.phabricator.com/D18511
This commit is contained in:
parent
86779b1526
commit
213ed3ff15
4 changed files with 31 additions and 2 deletions
|
@ -90,6 +90,7 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer {
|
|||
|
||||
$old = $data;
|
||||
$old_lines = phutil_split_lines($old);
|
||||
$start = $line;
|
||||
|
||||
if ($message->isPatchable()) {
|
||||
$patch_offset = $line_map[$line] + ($char - 1);
|
||||
|
@ -107,8 +108,6 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer {
|
|||
$old_impact = substr_count($original, "\n") + 1;
|
||||
$new_impact = substr_count($replacement, "\n") + 1;
|
||||
|
||||
$start = $line;
|
||||
|
||||
// If lines at the beginning of the changed line range are actually the
|
||||
// same, shrink the range. This happens when a patch just adds a line.
|
||||
do {
|
||||
|
@ -214,6 +213,14 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer {
|
|||
$spec['text'],
|
||||
$chevron,
|
||||
idx($spec, 'type'));
|
||||
|
||||
// If this is just a message and does not have a patch, put a little
|
||||
// caret underneath the line to point out where the issue is.
|
||||
if ($chevron) {
|
||||
if (!$message->isPatchable() && !strlen($original)) {
|
||||
$result[] = $this->renderCaret($char)."\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return implode('', $result);
|
||||
|
|
|
@ -54,6 +54,13 @@ final class ArcanistConsoleLintRendererTestCase
|
|||
'original' => '',
|
||||
'replacement' => "\n",
|
||||
),
|
||||
|
||||
'caret' => array(
|
||||
'line' => 2,
|
||||
'char' => 13,
|
||||
'name' => 'Fruit Misinformation',
|
||||
'description' => 'Arguably untrue.',
|
||||
),
|
||||
);
|
||||
|
||||
$defaults = array(
|
||||
|
|
11
src/lint/renderer/__tests__/data/caret.expect
Normal file
11
src/lint/renderer/__tests__/data/caret.expect
Normal file
|
@ -0,0 +1,11 @@
|
|||
>>> Lint for path/to/example.c:
|
||||
|
||||
|
||||
Warning (WARN123) Fruit Misinformation
|
||||
Arguably untrue.
|
||||
|
||||
1 Apples are round.
|
||||
>>> 2 Bananas are round.
|
||||
^
|
||||
3 Cherries are round.
|
||||
4 Dates are round.
|
4
src/lint/renderer/__tests__/data/caret.txt
Normal file
4
src/lint/renderer/__tests__/data/caret.txt
Normal file
|
@ -0,0 +1,4 @@
|
|||
Apples are round.
|
||||
Bananas are round.
|
||||
Cherries are round.
|
||||
Dates are round.
|
Loading…
Reference in a new issue