1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2026-10-29 06:12:56 +03:00
Files
lazygit/pkg/commands/patch
Stefan Haller 80dff3c2b9 Number the lines of a diff in one pass when parsing it
With no diff renderer configured, opening the jump-to-file menu for the
diff of a commit that adds or deletes a file of 100,000 lines takes
more than 20 seconds, and so does picking a file from it. In such a
diff, moving the selection by change block takes as long for each key
press. All this time the UI is frozen.

To find out which line of which file each row of the main view shows,
lazygit parses the view's content as a diff. For every line of a file's
diff it asks the parsed patch for the line's number in the new and in
the old file, and each of these calls counts the lines of the hunk
before it. So parsing takes time quadratic in the length of a hunk, and
the diff of a new or deleted file is a single hunk. For a diff of
200,000 lines, one parse took about 10 seconds, and opening the menu
parses it twice. A diff renderer that states which line each row shows,
such as delta, doesn't go through this parse.

Number all lines of the patch in one pass instead. Parsing that diff
now takes about 40 milliseconds.

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
2026-10-14 08:41:50 +02:00
..
2025-07-04 10:14:35 +02:00