mirror of
				https://github.com/jesseduffield/lazygit.git
				synced 2025-10-30 23:57:43 +02:00 
			
		
		
		
	Fix truncation of long branch names containing non-ASCII characters
This commit is contained in:
		| @@ -79,10 +79,10 @@ func getBranchDisplayStrings( | ||||
| 	} | ||||
|  | ||||
| 	// Don't bother shortening branch names that are already 3 characters or less | ||||
| 	if len(displayName) > max(availableWidth, 3) { | ||||
| 	if runewidth.StringWidth(displayName) > max(availableWidth, 3) { | ||||
| 		// Never shorten the branch name to less then 3 characters | ||||
| 		len := max(availableWidth, 4) | ||||
| 		displayName = displayName[:len-1] + "…" | ||||
| 		displayName = runewidth.Truncate(displayName, len, "…") | ||||
| 	} | ||||
| 	coloredName := nameTextStyle.Sprint(displayName) | ||||
| 	if checkedOutByWorkTree { | ||||
|   | ||||
| @@ -51,7 +51,7 @@ func Test_getBranchDisplayStrings(t *testing.T) { | ||||
| 			useIcons:             false, | ||||
| 			checkedOutByWorktree: false, | ||||
| 			showDivergenceCfg:    "none", | ||||
| 			expected:             []string{"1m", "🍉_special_c…"}, // truncated, but shouldn't | ||||
| 			expected:             []string{"1m", "🍉_special_char"}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			branch:               &models.Branch{Name: "branch_name", Recency: "1m"}, | ||||
| @@ -202,7 +202,7 @@ func Test_getBranchDisplayStrings(t *testing.T) { | ||||
| 			useIcons:             false, | ||||
| 			checkedOutByWorktree: false, | ||||
| 			showDivergenceCfg:    "none", | ||||
| 			expected:             []string{"1m", "🍉_special_…"}, // truncated two runes too much | ||||
| 			expected:             []string{"1m", "🍉_special_ch…"}, | ||||
| 		}, | ||||
| 		{ | ||||
| 			branch:               &models.Branch{Name: "branch_name", Recency: "1m"}, | ||||
|   | ||||
		Reference in New Issue
	
	Block a user