Repository navigation
Patch formatter refactor - #425
Conversation
Just to make sure I'm not missing anything obvious here 1. startLine and endLine are both const 2. endLine is always equal to startLine 3. startLine is always equal to endLine, 4. Both are equal to rowIndex 5. Both can be substituted for rowIndex 6. if `i = rowIndex` then `i <= rowIndex` is only true once given that i increments 7. So the for statement is only executed once, ie it's redundant
…formatter-sparkles
…formatter-sparkles
... and that's to be expected, stay tuned
Those are for human readability and add nothing to the processing of a patch by apply
…formatter-sparkles
| const sectionHeading = m[5] || null | ||
|
|
||
| return new DiffHunkHeader(oldStartLine, oldLineCount, newStartLine, newLineCount) | ||
| return new DiffHunkHeader(oldStartLine, oldLineCount, newStartLine, newLineCount, sectionHeading) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
This is now ready for review! 🎉 I do apologize for the size of this PR but it was inevitable. In LoC speaking this leaves us with less code but the documentation, comments and tests push this into the green. What's happenedDiffs no longer carry selection stateWe used to have two sources of truth for whether a line was selected or not, first a DiffSelection
|
| const sectionHeading = m[5] || null | ||
|
|
||
| return new DiffHunkHeader(oldStartLine, oldLineCount, newStartLine, newLineCount) | ||
| return new DiffHunkHeader(oldStartLine, oldLineCount, newStartLine, newLineCount, sectionHeading) |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * | ||
| * Note that this multi-line string includes a trailing newline. | ||
| * | ||
| * @param from The relative path to the original version of the file or |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| // > [...] the original file is preceded by "---" and the new file is preceded | ||
| // > by "+++". | ||
| // | ||
| // We skip the time stamp since to match git |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| // > | ||
| // > In many versions of GNU diff, each range can omit the comma and trailing value s, | ||
| // > in which case s defaults to 1 | ||
| const lineInfoBefore = oldLineCount === 1 |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if (line.type === DiffLineType.Delete) { | ||
| hunkBuf += ` ${line.text.substr(1)}\n` | ||
| oldCount++ | ||
| newCount++ |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if (line.type === DiffLineType.Add) { newCount++ } | ||
| if (line.type === DiffLineType.Delete) { oldCount++ } | ||
|
|
||
| anyAdditionsOrDeletions = true |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| * | ||
| * The selection can then be transformed by marking a line or a range of lines | ||
| * as selected or not selected. Internally the class maintains a list of lines | ||
| * whose selection state has diverged from the default selection state. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
💅 |
|
Cornflakes! |
…formatter-sparkles
|
💆♂️ |
|
CI has some cause for upset. |
|
🐸 |


Gonna try moving the diff loading out of the Diff component before tackling this head on but opening up as a WIP to show that it's being worked on