diff options
author | Junegunn Choi <junegunn.c@gmail.com> | 2018-04-12 17:49:52 +0900 |
---|---|---|
committer | Junegunn Choi <junegunn.c@gmail.com> | 2018-04-12 17:49:52 +0900 |
commit | f57920ad903105381b02502580be2bb11e4e6714 (patch) | |
tree | a2e92a8bb9925b842a34c19c6e6e3ebc2d00bf8f /src/util | |
parent | 7dbbbef51afe071f9a725cf7dccf4fb2aafd8e3f (diff) |
Do not print non-displayable characters
fzf used to print non-displayable characters (ascii code < 32) as '?',
but we will simply ignore those characters with this patch, just like
our terminals do.
\n and \r are exceptions. They will be printed as a space character.
TODO: \H should delete the preceding character, but this is not implemented.
Related: #1253
Diffstat (limited to 'src/util')
-rw-r--r-- | src/util/util.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/util/util.go b/src/util/util.go index 867935ac..95c4e1b4 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -17,11 +17,12 @@ func RuneWidth(r rune, prefixWidth int, tabstop int) int { return tabstop - prefixWidth%tabstop } else if w, found := _runeWidths[r]; found { return w - } else { - w := Max(runewidth.RuneWidth(r), 1) - _runeWidths[r] = w - return w + } else if r == '\n' || r == '\r' { + return 1 } + w := runewidth.RuneWidth(r) + _runeWidths[r] = w + return w } // Max returns the largest integer |