mirror of
				https://github.com/vim/vim.git
				synced 2025-10-30 09:47:20 -04:00 
			
		
		
		
	patch 9.1.1018: v9.1.0743 causes regression with diff mode
Problem: v9.1.0743 causes regression with diff mode Solution: Fix the regression with overlapping regions closes: #16454 Signed-off-by: Yukihiro Nakadaira <yukihiro.nakadaira@gmail.com> Signed-off-by: Christian Brabandt <cb@256bit.org>
This commit is contained in:
		
				
					committed by
					
						 Christian Brabandt
						Christian Brabandt
					
				
			
			
				
	
			
			
			
						parent
						
							6472e58365
						
					
				
				
					commit
					01f6509fb2
				
			
							
								
								
									
										10
									
								
								src/diff.c
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/diff.c
									
									
									
									
									
								
							| @@ -1824,8 +1824,14 @@ diff_read( | |||||||
| 		dp->df_count[idx_new] = hunk->count_new - off; | 		dp->df_count[idx_new] = hunk->count_new - off; | ||||||
| 	    } | 	    } | ||||||
| 	    else | 	    else | ||||||
|  | 	    { | ||||||
| 		// second overlap of new block with existing block | 		// second overlap of new block with existing block | ||||||
| 		dp->df_count[idx_new] += hunk->count_new; | 		dp->df_count[idx_new] += hunk->count_new; | ||||||
|  | 		if ((dp->df_lnum[idx_new] + dp->df_count[idx_new] - 1) | ||||||
|  | 			> curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count) | ||||||
|  | 		    dp->df_count[idx_new] = curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count | ||||||
|  | 			- dp->df_lnum[idx_new] + 1; | ||||||
|  | 	    } | ||||||
|  |  | ||||||
| 	    // Adjust the size of the block to include all the lines to the | 	    // Adjust the size of the block to include all the lines to the | ||||||
| 	    // end of the existing block or the new diff, whatever ends last. | 	    // end of the existing block or the new diff, whatever ends last. | ||||||
| @@ -1835,6 +1841,10 @@ diff_read( | |||||||
| 	    { | 	    { | ||||||
| 		// new change ends in existing block, adjust the end | 		// new change ends in existing block, adjust the end | ||||||
| 		dp->df_count[idx_new] += -off; | 		dp->df_count[idx_new] += -off; | ||||||
|  | 		if ((dp->df_lnum[idx_new] + dp->df_count[idx_new] - 1) | ||||||
|  | 			> curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count) | ||||||
|  | 		    dp->df_count[idx_new] = curtab->tp_diffbuf[idx_new]->b_ml.ml_line_count | ||||||
|  | 			- dp->df_lnum[idx_new] + 1; | ||||||
| 		off = 0; | 		off = 0; | ||||||
| 	    } | 	    } | ||||||
| 	    for (i = idx_orig; i < idx_new; ++i) | 	    for (i = idx_orig; i < idx_new; ++i) | ||||||
|   | |||||||
							
								
								
									
										20
									
								
								src/testdir/dumps/Test_diff_overlapped_3.38.dump
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/testdir/dumps/Test_diff_overlapped_3.38.dump
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | | +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|d+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@20 | ||||||
|  | | +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|e+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|f+2#0000000#ff404010| +0&#ffd7ff255@20 | ||||||
|  | | +0#0000e05#a8a8a8255@1|c+0#0000000#5fd7ff255| @21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21 | ||||||
|  | |~+0&#ffffff0| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |X+3#0000000&|d|i|f|i|l|e|1| @4|1|,|1| @5|A|l@1| |X+1&&|d|i|f|i|l|e|2| @3|1|,|1| @5|A|l@1| |X|d|i|f|i|l|e|3| @3|1|,|1| @5|A|l@1 | ||||||
|  | |:+0&&> @73 | ||||||
							
								
								
									
										20
									
								
								src/testdir/dumps/Test_diff_overlapped_3.39.dump
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										20
									
								
								src/testdir/dumps/Test_diff_overlapped_3.39.dump
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,20 @@ | |||||||
|  | | +0#0000e05#a8a8a8255@1|a+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|d+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@20 | ||||||
|  | | +0#0000e05#a8a8a8255@1|b+2#0000000#ff404010| +0&#ffd7ff255@21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|e+2#0000000#ff404010| +0&#ffd7ff255@20||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21 | ||||||
|  | | +0#0000e05#a8a8a8255@1|c+0#0000000#5fd7ff255| @21||+1&#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21||+1#0000000#ffffff0| +0#0000e05#a8a8a8255@1|-+0#4040ff13#afffff255@21 | ||||||
|  | |~+0&#ffffff0| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |~| @23||+1#0000000&|~+0#4040ff13&| @22||+1#0000000&|~+0#4040ff13&| @22 | ||||||
|  | |X+3#0000000&|d|i|f|i|l|e|1| @4|1|,|1| @5|A|l@1| |X+1&&|d|i|f|i|l|e|2| @3|1|,|1| @5|A|l@1| |X|d|i|f|i|l|e|3| @3|1|,|1| @5|A|l@1 | ||||||
|  | |:+0&&> @73 | ||||||
| @@ -2290,6 +2290,12 @@ func Test_diff_overlapped_diff_blocks_will_be_merged() | |||||||
|   call WriteDiffFiles3(buf, ["a", "b", "c"], ["a", "x", "c"], ["a", "y", "b", "c"]) |   call WriteDiffFiles3(buf, ["a", "b", "c"], ["a", "x", "c"], ["a", "y", "b", "c"]) | ||||||
|   call VerifyBoth(buf, "Test_diff_overlapped_3.36", "") |   call VerifyBoth(buf, "Test_diff_overlapped_3.36", "") | ||||||
|  |  | ||||||
|  |   call WriteDiffFiles3(buf, ["a", "b", "c"], ["a", "x", "c"], ["a", "b", "y", "c"]) | ||||||
|  |   call VerifyBoth(buf, "Test_diff_overlapped_3.37", "") | ||||||
|  |  | ||||||
|  |   call WriteDiffFiles3(buf, ["a", "b", "c"], ["d", "e"], ["b", "f"]) | ||||||
|  |   call VerifyBoth(buf, "Test_diff_overlapped_3.38", "") | ||||||
|  |  | ||||||
|   call WriteDiffFiles3(buf, ["a", "b", "c"], ["d", "e"], ["b"]) |   call WriteDiffFiles3(buf, ["a", "b", "c"], ["d", "e"], ["b"]) | ||||||
|   call VerifyBoth(buf, "Test_diff_overlapped_3.39", "") |   call VerifyBoth(buf, "Test_diff_overlapped_3.39", "") | ||||||
|  |  | ||||||
|   | |||||||
| @@ -704,6 +704,8 @@ static char *(features[]) = | |||||||
|  |  | ||||||
| static int included_patches[] = | static int included_patches[] = | ||||||
| {   /* Add new patch number below this line */ | {   /* Add new patch number below this line */ | ||||||
|  | /**/ | ||||||
|  |     1018, | ||||||
| /**/ | /**/ | ||||||
|     1017, |     1017, | ||||||
| /**/ | /**/ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user