Open Nadrieril opened 3 years ago
I think it's not on rust-analyzer side, this is a common issue for all languages, vscode can have a resolve confolicts
mode which disables temporarily diagnostics.
What do other IDEs do?
Would be kinda cool though.
The cheapest thing to do would be to use the first block and skip the second block. That way the rest of the file would parse nicely and you would avoid the ugly sea of red.
That's probably a lot cheaper to implement and would make all the difference. (maybe have a setting to say always take the first or the second conflict chunk?)
Note that rustc detects merge conflicts nicely now. Looks like this:
error: encountered diff marker
--> compiler/rustc_pattern_analysis/src/lib.rs:49:1
|
49 | <<<<<<< HEAD
| ^^^^^^^ after this is the code before the merge
...
53 | ||||||| parent of 0bb9d9e0111 (Remove Ty: Copy bound)
| -------
54 | type Ty: Copy + Clone + fmt::Debug; // FIXME: remove Copy
55 | =======
| -------
56 | type Ty: Clone + fmt::Debug;
57 | >>>>>>> 0bb9d9e0111 (Remove Ty: Copy bound)
| ^^^^^^^ above this are the incoming code changes
|
= help: if you're having merge conflicts after pulling new code, the top section is the code you already had and the bottom section is the remote code
= help: if you're in the middle of a rebase, the top section is the code being rebased onto and the bottom section is the code coming from the current commit being rebased
I agree we should detect this to some degree at least, rustc PR that introduced this for inspiration: https://github.com/rust-lang/rust/pull/106242
One feature related to handling merge conflicts that would save me a lot of headaches would be to resolve a merge conflict in imports by merging the respective imports. For example, this is a very common conflict, where one commit added B
to the imports and the other commit added C
:
<<<<<< HEAD
use crate::{A, B};
======
use crate::{A, C};
>>>>>>
In this case, an assist to merge these would be awesome.
@Jesse-Bakker Technically, this can be achieved by accepting both and configuring rustfmt import granularity. Though I agree an assist would be nice.
A regular source of annoyance for me is the flurry of error messages when I am resolving a merge conflict. There are syntax errors everywhere which make the code hard to read. Could rust-analyzer notice merge conflicts and refrain from emitting too many syntax errors? Maybe just a single error "syntax error: this is a merge conflict". More far-fetched would be if ra could actually process both versions in parallel (or all 3 of them in 3-way merges), but I won't hold my breath x)