From eec1c718806797b21ba5f6c1ceddf711e9d4801a Mon Sep 17 00:00:00 2001 From: silverwind Date: Sat, 19 Nov 2022 12:08:06 +0100 Subject: Show syntax lexer name in file view/blame (#21814) Show which Chroma Lexer is used to highlight the file in the file header. It's useful for development to see what was detected, and I think it's not bad info to have for the user: Screenshot 2022-11-14 at 22 31 16 Screenshot 2022-11-14 at 22 36 06 Screenshot 2022-11-14 at 22 36 26 Also, I improved the way this header overflows on small screens: Screenshot 2022-11-14 at 22 44 36 Co-authored-by: delvh Co-authored-by: Lauris BH Co-authored-by: Lunny Xiao Co-authored-by: John Olheiser --- modules/util/util.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'modules/util') diff --git a/modules/util/util.go b/modules/util/util.go index be60fe4b4b..6df47ca568 100644 --- a/modules/util/util.go +++ b/modules/util/util.go @@ -186,13 +186,21 @@ func ToUpperASCII(s string) string { return string(b) } -var titleCaser = cases.Title(language.English) +var ( + titleCaser = cases.Title(language.English) + titleCaserNoLower = cases.Title(language.English, cases.NoLower) +) // ToTitleCase returns s with all english words capitalized func ToTitleCase(s string) string { return titleCaser.String(s) } +// ToTitleCaseNoLower returns s with all english words capitalized without lowercasing +func ToTitleCaseNoLower(s string) string { + return titleCaserNoLower.String(s) +} + var ( whitespaceOnly = regexp.MustCompile("(?m)^[ \t]+$") leadingWhitespace = regexp.MustCompile("(?m)(^[ \t]*)(?:[^ \t\n])") -- cgit v1.2.3