Display specific message if diff is not displayed because of too long line (#15611)
* 7184- message if line too long * Update options/locale/locale_en-US.ini Co-authored-by: silverwind <me@silverwind.io> * add flag on missing cases Signed-off-by: Andrew Thornton <art27@cantab.net> Co-authored-by: silverwind <me@silverwind.io> Co-authored-by: Andrew Thornton <art27@cantab.net>
This commit is contained in:
		
							parent
							
								
									1cd301796c
								
							
						
					
					
						commit
						34b21625c2
					
				
					 3 changed files with 27 additions and 16 deletions
				
			
		|  | @ -1887,6 +1887,7 @@ diff.file_image_width = Width | ||||||
| diff.file_image_height = Height | diff.file_image_height = Height | ||||||
| diff.file_byte_size = Size | diff.file_byte_size = Size | ||||||
| diff.file_suppressed = File diff suppressed because it is too large | diff.file_suppressed = File diff suppressed because it is too large | ||||||
|  | diff.file_suppressed_line_too_long = File diff suppressed because one or more lines are too long | ||||||
| diff.too_many_files = Some files were not shown because too many files changed in this diff | diff.too_many_files = Some files were not shown because too many files changed in this diff | ||||||
| diff.comment.placeholder = Leave a comment | diff.comment.placeholder = Leave a comment | ||||||
| diff.comment.markdown_info = Styling with markdown is supported. | diff.comment.markdown_info = Styling with markdown is supported. | ||||||
|  |  | ||||||
|  | @ -574,21 +574,22 @@ func (diffSection *DiffSection) GetComputedInlineDiffFor(diffLine *DiffLine) tem | ||||||
| 
 | 
 | ||||||
| // DiffFile represents a file diff.
 | // DiffFile represents a file diff.
 | ||||||
| type DiffFile struct { | type DiffFile struct { | ||||||
| 	Name               string | 	Name                    string | ||||||
| 	OldName            string | 	OldName                 string | ||||||
| 	Index              int | 	Index                   int | ||||||
| 	Addition, Deletion int | 	Addition, Deletion      int | ||||||
| 	Type               DiffFileType | 	Type                    DiffFileType | ||||||
| 	IsCreated          bool | 	IsCreated               bool | ||||||
| 	IsDeleted          bool | 	IsDeleted               bool | ||||||
| 	IsBin              bool | 	IsBin                   bool | ||||||
| 	IsLFSFile          bool | 	IsLFSFile               bool | ||||||
| 	IsRenamed          bool | 	IsRenamed               bool | ||||||
| 	IsAmbiguous        bool | 	IsAmbiguous             bool | ||||||
| 	IsSubmodule        bool | 	IsSubmodule             bool | ||||||
| 	Sections           []*DiffSection | 	Sections                []*DiffSection | ||||||
| 	IsIncomplete       bool | 	IsIncomplete            bool | ||||||
| 	IsProtected        bool | 	IsIncompleteLineTooLong bool | ||||||
|  | 	IsProtected             bool | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| // GetType returns type of diff file.
 | // GetType returns type of diff file.
 | ||||||
|  | @ -935,6 +936,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio | ||||||
| 	for { | 	for { | ||||||
| 		for isFragment { | 		for isFragment { | ||||||
| 			curFile.IsIncomplete = true | 			curFile.IsIncomplete = true | ||||||
|  | 			curFile.IsIncompleteLineTooLong = true | ||||||
| 			_, isFragment, err = input.ReadLine() | 			_, isFragment, err = input.ReadLine() | ||||||
| 			if err != nil { | 			if err != nil { | ||||||
| 				// Now by the definition of ReadLine this cannot be io.EOF
 | 				// Now by the definition of ReadLine this cannot be io.EOF
 | ||||||
|  | @ -1062,6 +1064,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio | ||||||
| 		line := string(lineBytes) | 		line := string(lineBytes) | ||||||
| 		if isFragment { | 		if isFragment { | ||||||
| 			curFile.IsIncomplete = true | 			curFile.IsIncomplete = true | ||||||
|  | 			curFile.IsIncompleteLineTooLong = true | ||||||
| 			for isFragment { | 			for isFragment { | ||||||
| 				lineBytes, isFragment, err = input.ReadLine() | 				lineBytes, isFragment, err = input.ReadLine() | ||||||
| 				if err != nil { | 				if err != nil { | ||||||
|  | @ -1073,6 +1076,7 @@ func parseHunks(curFile *DiffFile, maxLines, maxLineCharacters int, input *bufio | ||||||
| 		} | 		} | ||||||
| 		if len(line) > maxLineCharacters { | 		if len(line) > maxLineCharacters { | ||||||
| 			curFile.IsIncomplete = true | 			curFile.IsIncomplete = true | ||||||
|  | 			curFile.IsIncompleteLineTooLong = true | ||||||
| 			line = line[:maxLineCharacters] | 			line = line[:maxLineCharacters] | ||||||
| 		} | 		} | ||||||
| 		curSection.Lines[len(curSection.Lines)-1].Content = line | 		curSection.Lines[len(curSection.Lines)-1].Content = line | ||||||
|  |  | ||||||
|  | @ -53,7 +53,13 @@ | ||||||
| 						</div> | 						</div> | ||||||
| 						<span class="file mono">{{$file.Name}}</span> | 						<span class="file mono">{{$file.Name}}</span> | ||||||
| 						<div class="diff-file-header-actions df ac"> | 						<div class="diff-file-header-actions df ac"> | ||||||
| 							<div class="text grey">{{$.i18n.Tr "repo.diff.file_suppressed"}}</div> | 							<div class="text grey"> | ||||||
|  | 								{{if $file.IsIncompleteLineTooLong}} | ||||||
|  | 									{{$.i18n.Tr "repo.diff.file_suppressed_line_too_long"}} | ||||||
|  | 								{{else}} | ||||||
|  | 									{{$.i18n.Tr "repo.diff.file_suppressed"}} | ||||||
|  | 								{{end}} | ||||||
|  | 							</div> | ||||||
| 							{{if $file.IsProtected}} | 							{{if $file.IsProtected}} | ||||||
| 								<span class="ui basic label">{{$.i18n.Tr "repo.diff.protected"}}</span> | 								<span class="ui basic label">{{$.i18n.Tr "repo.diff.protected"}}</span> | ||||||
| 							{{end}} | 							{{end}} | ||||||
|  |  | ||||||
		Loading…
	
		Reference in a new issue