summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJunegunn Choi <junegunn.c@gmail.com>2020-08-02 10:02:11 +0900
committerJunegunn Choi <junegunn.c@gmail.com>2020-08-02 10:03:17 +0900
commit92b7efafcacfa5c5de2a8f22abd859b8fc994748 (patch)
tree8d528a73a88a3339b7dbcd5e87d9dd166b8b03f9 /src
parentf092e4038fd1344bcd0a7c11f7ab7355734f7275 (diff)
downloadfzf-92b7efafcacfa5c5de2a8f22abd859b8fc994748.tar.gz
Ignore punctuation characters before and after preview offset column
This is to allow line numbers in a ctags output (e.g. 123;")
Diffstat (limited to 'src')
-rw-r--r--src/terminal.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/terminal.go b/src/terminal.go
index 87703d3e..a7e9e9b2 100644
--- a/src/terminal.go
+++ b/src/terminal.go
@@ -23,12 +23,14 @@ import (
// import "github.com/pkg/profile"
var placeholder *regexp.Regexp
+var numericPrefix *regexp.Regexp
var activeTempFiles []string
const ellipsis string = ".."
func init() {
placeholder = regexp.MustCompile(`\\?(?:{[+sf]*[0-9,-.]*}|{q}|{\+?f?nf?})`)
+ numericPrefix = regexp.MustCompile(`^[[:punct:]]*([0-9]+)`)
activeTempFiles = []string{}
}
@@ -1361,7 +1363,11 @@ func (t *Terminal) replacePlaceholder(template string, forcePlus bool, input str
// Ascii to positive integer
func atopi(s string) int {
- n, e := strconv.Atoi(strings.ReplaceAll(s, "'", ""))
+ matches := numericPrefix.FindStringSubmatch(s)
+ if len(matches) < 2 {
+ return 0
+ }
+ n, e := strconv.Atoi(matches[1])
if e != nil || n < 1 {
return 0
}