mirror of
https://we.phorge.it/source/arcanist.git
synced 2024-11-25 08:12:40 +01:00
Fix an issue when rendering a lint message which removes whitespace at the end of a file
Summary: Ref T13543. If a file ends in spaces and no newline, we'll emit a message suggesting removal of the spaces. This will effectively remove the line, but the code will then attempt to highlight text within the line. Prior to D21044 this continued without raising an error and produced a reasonable result, but it now fatals. Insetad, don't try to highlight lines which no longer exist. Test Plan: See T13543 for details. Maniphest Tasks: T13543 Differential Revision: https://secure.phabricator.com/D21290
This commit is contained in:
parent
25ee39b657
commit
e69aa32603
1 changed files with 10 additions and 5 deletions
|
@ -146,11 +146,16 @@ final class ArcanistConsoleLintRenderer extends ArcanistLintRenderer {
|
|||
$char - 1,
|
||||
strlen($original));
|
||||
|
||||
$new_lines[$start - 1] = substr_replace(
|
||||
$new_lines[$start - 1],
|
||||
$this->highlightText($replacement),
|
||||
$char - 1,
|
||||
strlen($replacement));
|
||||
// See T13543. The message may have completely removed this line: for
|
||||
// example, if it trimmed trailing spaces from the end of a file. If
|
||||
// the line no longer exists, don't try to highlight it.
|
||||
if (isset($new_lines[$start - 1])) {
|
||||
$new_lines[$start - 1] = substr_replace(
|
||||
$new_lines[$start - 1],
|
||||
$this->highlightText($replacement),
|
||||
$char - 1,
|
||||
strlen($replacement));
|
||||
}
|
||||
}
|
||||
|
||||
// If lines at the beginning of the changed line range are actually the
|
||||
|
|
Loading…
Reference in a new issue