mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-22 05:20:56 +01:00
Don't ignore internal whitespace changes in "Whitespace: Ignore All"
Summary: When whitespace changes between two non-whitespace characters (e.g., in a string), always treat it as a change. Test Plan: Disabled render cache, made internal and external whitespace changes, rendered a diff, got internal change always marked and external change marked correctly depending on mode. Reviewed By: tuomaspelkonen Reviewers: tuomaspelkonen CC: aran, tuomaspelkonen, epriestley Differential Revision: 403
This commit is contained in:
parent
b8194202e6
commit
404c3283cb
1 changed files with 21 additions and 1 deletions
|
@ -404,6 +404,26 @@ class DifferentialChangesetParser {
|
|||
continue;
|
||||
}
|
||||
$new[$k]['text'] = idx($new_text, $desc['line']);
|
||||
|
||||
// If there's a corresponding "old" text and the line is marked as
|
||||
// unchanged, test if there are internal whitespace changes between
|
||||
// non-whitespace characters, e.g. spaces added to a string or spaces
|
||||
// added around operators. If we find internal spaces, mark the line
|
||||
// as changed.
|
||||
//
|
||||
// We only need to do this for "new" lines because any line that is
|
||||
// missing either "old" or "new" text certainly can not have internal
|
||||
// whitespace changes without also having non-whitespace changes,
|
||||
// because characters had to be either added or removed to create the
|
||||
// possibility of internal whitespace.
|
||||
if (isset($old[$k]['text']) && empty($new[$k]['type'])) {
|
||||
if (trim($old[$k]['text']) != trim($new[$k]['text'])) {
|
||||
// The strings aren't the same when trimmed, so there are internal
|
||||
// whitespace changes. Mark this line changed.
|
||||
$old[$k]['type'] = '-';
|
||||
$new[$k]['type'] = '+';
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$this->old = $old;
|
||||
|
@ -725,7 +745,7 @@ class DifferentialChangesetParser {
|
|||
Filesystem::writeFile($old_tmp, $changeset->makeOldFile());
|
||||
Filesystem::writeFile($new_tmp, $changeset->makeNewFile());
|
||||
list($err, $diff) = exec_manual(
|
||||
'diff -bw -U65535 %s %s',
|
||||
'diff -bw -U65535 %s %s ',
|
||||
$old_tmp,
|
||||
$new_tmp);
|
||||
|
||||
|
|
Loading…
Reference in a new issue