Commit graph

38 commits

Author SHA1 Message Date
Stefan Haller d0078bf05c Recognize conflict markers that have no label
Git only writes the space after a marker when there is a label to write
after it, and the label can be empty: `git checkout -m` with the diff3
conflict style, for instance, has no name for the common ancestor, so it
writes a bare "|||||||" line.
2026-08-08 12:43:42 +02:00
Stefan Haller bc9fafff02 Make the conflict marker size a parameter of our marker matching
Git doesn't always write conflict markers of seven characters: the
conflict-marker-size gitattribute overrides that per file, and it is set
for good reasons — for file types whose regular content tends to contain
marker-looking lines, such as documentation about merging, or test
scripts. We hard-code seven characters everywhere we look for markers,
so none of that works.

Prepare for honoring the attribute by threading the marker size through
everything that recognizes a marker, carried on the file model. Nothing
fills it in yet, so we still use git's default size of seven everywhere,
and matching is unchanged: a marker consists of exactly that many marker
characters, and all but the "=======" one are followed by a space and a
label.
2026-08-08 12:43:42 +02:00
Stefan Haller ed3f4db4f9 Pick both hunks, not the common ancestor, in diff3 conflicts
`b` on a merge conflict is meant to keep both sides. With the diff3
conflict style git additionally renders the common ancestor between the
two sides, and the old ALL selection kept everything between the
outermost markers, dragging that ancestor into the resolved file.

Rename the selection from ALL to BOTH and restrict it to the top and
bottom hunks so the common base is dropped. Without the diff3 style
there is no ancestor section, so the behaviour there is unchanged.

The user-facing keybinding config was already named pickBothHunks; only
the internal enum, handler, translation and log string still said "all".

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-07-01 09:57:26 +02:00
Stefan Haller 8dbdd74400 Fix linter warnings about ignoring errors from bufio.Scanner 2026-05-03 16:57:24 +02:00
Stefan Haller 562d0541a1 Fix linter warning about inefficient string concatenation 2026-05-03 16:39:41 +02:00
Stefan Haller ca05a2ccea Enable revive linter, and fix a bunch of warnings
I took the set of enabled checks from revive's recommended configuration [1],
and removed some that I didn't like. There might be other useful checks in
revive that we might want to enable, but this is a nice improvement already.

The bulk of the changes here are removing unnecessary else statements after
returns, but there are a few others too.

[1] https://github.com/mgechev/revive?tab=readme-ov-file#recommended-configuration
2025-06-30 19:13:20 +02:00
Stefan Haller b97dd6bc3f Remove utils.Clamp, use lo.Clamp instead 2025-04-21 18:03:18 +02:00
Jesse Duffield fdff2dec79 Remove redundant variable dedeclarations
In go 1.22, loop variables are redeclared with each iteration of the
loop, rather than simple updated on each iteration. This means that we
no longer need to manually redeclare variables when they're closed over
by a function.
2024-05-19 16:38:21 +10:00
Stefan Haller f69eb6dc48 Use ScanLinesAndTruncateWhenLongerThanBuffer instead of bufio.ScanLines 2024-05-15 13:27:01 +02:00
Jesse Duffield f3eb180f75 Standardise display of range selection across views
We're not fully standardising here: different contexts can store their range state however
they like. What we are standardising on is that now the view is always responsible for
highlighting the selected lines, meaning the context/controller needs to tell the view
where the range start is.

Two convenient benefits from this change:
1) we no longer need bespoke code in integration tests for asserting on selected lines because
we can just ask the view
2) line selection in staging/patch-building/merge-conflicts views now look the same as in
list views i.e. the highlight applies to the whole line (including trailing space)

I also noticed a bug with merge conflicts not rendering the selection on focus though I suspect
it wasn't a bug with any real consequences when the view wasn't displaying the selection.

I'm going to scrap the selectedRangeBgColor config and just let it use the single line
background color. Hopefully nobody cares, but there's really no need for an extra config.
2024-01-19 10:47:21 +11:00
Jesse Duffield dd1bf629b8 migrate patch building tests 2023-02-25 21:37:16 +11:00
Jesse Duffield 7410acd1aa move merge conflicts code into controller 2022-08-07 11:16:03 +10:00
Jesse Duffield 3bf0c9ef44 more documentation 2022-05-07 16:02:04 +10:00
Ryooooooga 3b5a019e1a feat(merge_panel): Add open/edit files in merge conflict panel 2022-04-06 08:27:03 +10:00
Jesse Duffield a34bdf1a04 update linters 2022-03-19 12:12:57 +11:00
Jesse Duffield c084abb378 move more view model logic into the files view model 2022-03-17 19:13:40 +11:00
Jesse Duffield 84a1992055 better locking of merge panel state 2022-01-27 21:25:04 +11:00
Jesse Duffield c8cc18920f improve merge conflict flow 2022-01-26 14:50:47 +11:00
Jesse Duffield 44d08edfb0 Address feedback 2021-08-25 22:23:55 +10:00
Jesse Duffield f08fdb2873 Minor refactor 2021-08-25 22:23:55 +10:00
Ryooooooga 6ca42ff720 Fix pick all hunks 2021-08-25 22:23:55 +10:00
Ryooooooga a533f8e1a5 simplify merge panel logic 2021-08-25 22:23:55 +10:00
Ryooooooga cf8ded0b79 add mergeConflict#hasAncestor 2021-08-25 22:23:55 +10:00
Ryooooooga 73548fa15f Fix conflict resolution 2021-08-25 22:23:55 +10:00
Ryooooooga a0e7604f61 Support git config merge.conflictStyle diff3 2021-08-25 22:23:55 +10:00
Ryooooooga 0af0e66586
Fix panic in merge conflict 2021-08-21 18:34:30 +09:00
Jesse Duffield d626bcac00 color fixups 2021-08-01 16:14:56 +10:00
Jesse Duffield 117c0bd4f7 simplify code a bit 2021-07-31 17:33:13 +10:00
mjarkk 79848087bc Switch to github.com/gookit/color for terminal colors 2021-07-30 15:14:46 +02:00
Jesse Duffield 6d91661d5e prevent closure issue 2021-06-05 13:54:05 +10:00
Jesse Duffield 90983aae65 not importing regexp 2021-06-05 13:53:25 +10:00
Jesse Duffield f71b23b890 more explicit 2021-06-05 13:53:25 +10:00
Cristian Betivu 05a23f0e1e Discard value after END marker 2021-06-05 13:53:25 +10:00
Cristian Betivu fd38ad8096 More generic merge conflict detection 2021-06-05 13:53:25 +10:00
Jesse Duffield 258eedb38c refactor 2021-06-02 20:33:52 +10:00
Harrison Jones e478c254d4 Handle alternate merge conflict format; add tests 2021-05-30 13:50:42 +10:00
Jesse Duffield 98375dc902 refactor merge panel 2021-04-18 18:58:09 +10:00
Jesse Duffield eeeef9ca86 refactor 2021-04-02 11:09:12 +11:00