diff --git a/src/algo/algo.go b/src/algo/algo.go index 2fe5c091..a627514c 100644 --- a/src/algo/algo.go +++ b/src/algo/algo.go @@ -371,7 +371,7 @@ func FuzzyMatchV2(caseSensitive bool, normalize bool, forward bool, input *util. // The first occurrence of each character in the pattern offset32, F := alloc32(offset32, slab, M) // Rune array - offset32, T := alloc32(offset32, slab, N) + _, T := alloc32(offset32, slab, N) input.CopyRunes(T) // Phase 2. Calculate bonus for each point @@ -453,7 +453,7 @@ func FuzzyMatchV2(caseSensitive bool, normalize bool, forward bool, input *util. copy(H, H0[f0:lastIdx+1]) // Possible length of consecutive chunk at each position. - offset16, C := alloc16(offset16, slab, width*M) + _, C := alloc16(offset16, slab, width*M) copy(C, C0[f0:lastIdx+1]) Fsub := F[1:] diff --git a/src/options.go b/src/options.go index c394399d..2ab3a896 100644 --- a/src/options.go +++ b/src/options.go @@ -386,7 +386,7 @@ func parseKeyChords(str string, message string) map[int]string { } tokens := strings.Split(str, ",") - if str == "," || strings.HasPrefix(str, ",,") || strings.HasSuffix(str, ",,") || strings.Index(str, ",,,") >= 0 { + if str == "," || strings.HasPrefix(str, ",,") || strings.HasSuffix(str, ",,") || strings.Contains(str, ",,,") { tokens = append(tokens, ",") } @@ -628,7 +628,7 @@ func init() { // Backreferences are not supported. // "~!@#$%^&*;/|".each_char.map { |c| Regexp.escape(c) }.map { |c| "#{c}[^#{c}]*#{c}" }.join('|') executeRegexp = regexp.MustCompile( - "(?si):(execute(?:-multi|-silent)?):.+|:(execute(?:-multi|-silent)?)(\\([^)]*\\)|\\[[^\\]]*\\]|~[^~]*~|![^!]*!|@[^@]*@|\\#[^\\#]*\\#|\\$[^\\$]*\\$|%[^%]*%|\\^[^\\^]*\\^|&[^&]*&|\\*[^\\*]*\\*|;[^;]*;|/[^/]*/|\\|[^\\|]*\\|)") + `(?si):(execute(?:-multi|-silent)?):.+|:(execute(?:-multi|-silent)?)(\([^)]*\)|\[[^\]]*\]|~[^~]*~|![^!]*!|@[^@]*@|\#[^\#]*\#|\$[^\$]*\$|%[^%]*%|\^[^\^]*\^|&[^&]*&|\*[^\*]*\*|;[^;]*;|/[^/]*/|\|[^\|]*\|)`) } func parseKeymap(keymap map[int][]action, str string) { diff --git a/src/result.go b/src/result.go index 289d83a0..be325cbb 100644 --- a/src/result.go +++ b/src/result.go @@ -16,7 +16,6 @@ type colorOffset struct { offset [2]int32 color tui.ColorPair attr tui.Attr - index int32 } type Result struct { diff --git a/src/terminal.go b/src/terminal.go index 3e5683c6..3c656cce 100644 --- a/src/terminal.go +++ b/src/terminal.go @@ -26,7 +26,7 @@ var placeholder *regexp.Regexp var activeTempFiles []string func init() { - placeholder = regexp.MustCompile("\\\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\\+?f?nf?})") + placeholder = regexp.MustCompile(`\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\+?f?nf?})`) activeTempFiles = []string{} } @@ -1012,19 +1012,6 @@ func (t *Terminal) printHighlighted(result Result, attr tui.Attr, col1 tui.Color return displayWidth } -func numLinesMax(str string, max int) int { - lines := 0 - for lines < max { - idx := strings.Index(str, "\n") - if idx < 0 { - break - } - str = str[idx+1:] - lines++ - } - return lines -} - func (t *Terminal) printPreview() { if !t.hasPreviewWindow() { return diff --git a/src/terminal_test.go b/src/terminal_test.go index 8b828af4..74dd1066 100644 --- a/src/terminal_test.go +++ b/src/terminal_test.go @@ -89,7 +89,7 @@ func TestReplacePlaceholder(t *testing.T) { check("echo ' foo'\\''bar baz'") // Whitespace preserving flag with regex delimiter - regex = regexp.MustCompile("\\w+") + regex = regexp.MustCompile(`\w+`) result = replacePlaceholder("echo {s1}", true, Delimiter{regex: regex}, printsep, false, "query", items1) check("echo ' '") diff --git a/src/tui/light.go b/src/tui/light.go index 5d3eff88..43d7efee 100644 --- a/src/tui/light.go +++ b/src/tui/light.go @@ -713,10 +713,6 @@ func (w *LightWindow) csi(code string) { w.renderer.csi(code) } -func (w *LightWindow) stderr(str string) { - w.renderer.stderr(str) -} - func (w *LightWindow) stderrInternal(str string, allowNLCR bool) { w.renderer.stderrInternal(str, allowNLCR) } diff --git a/src/tui/tui.go b/src/tui/tui.go index be5bd26a..9b821940 100644 --- a/src/tui/tui.go +++ b/src/tui/tui.go @@ -117,7 +117,7 @@ func (c Color) is24() bool { const ( colUndefined Color = -2 - colDefault = -1 + colDefault Color = -1 ) const ( @@ -164,10 +164,6 @@ func (p ColorPair) Bg() Color { return p.bg } -func (p ColorPair) is24() bool { - return p.fg.is24() || p.bg.is24() -} - type ColorTheme struct { Fg Color Bg Color