diff options
| author | JINNOUCHI Yasushi <me@delphinus.dev> | 2021-06-15 03:47:33 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-06-14 20:47:33 +0200 |
| commit | 0c1bc129da3f684b04d72530dddaedb5255f12ef (patch) | |
| tree | 110622ddcdd5faaef686fc87c23a01300626f155 /lua/telescope/pickers/entry_display.lua | |
| parent | 398a0d391aa2afcda1521a8e86b820ffb599b60b (diff) | |
chore: use plenary.strings and remove strings functions from utils (#690)
Co-authored-by: Simon Hauser <Simon-Hauser@outlook.de>
Diffstat (limited to 'lua/telescope/pickers/entry_display.lua')
| -rw-r--r-- | lua/telescope/pickers/entry_display.lua | 29 |
1 files changed, 4 insertions, 25 deletions
diff --git a/lua/telescope/pickers/entry_display.lua b/lua/telescope/pickers/entry_display.lua index f64f693..e2be8c0 100644 --- a/lua/telescope/pickers/entry_display.lua +++ b/lua/telescope/pickers/entry_display.lua @@ -1,28 +1,7 @@ -local utils = require('telescope.utils') +local strings = require('plenary.strings') local entry_display = {} - -entry_display.truncate = function(str, len) - str = tostring(str) -- We need to make sure its an actually a string and not a number - if utils.strdisplaywidth(str) <= len then - return str - end - local charlen = 0 - local cur_len = 0 - local result = '' - local len_of_dots = utils.strdisplaywidth('…') - while true do - local part = utils.strcharpart(str, charlen, 1) - cur_len = cur_len + utils.strdisplaywidth(part) - if (cur_len + len_of_dots) > len then - result = result .. '…' - break - end - result = result .. part - charlen = charlen + 1 - end - return result -end +entry_display.truncate = strings.truncate entry_display.create = function(configuration) local generator = {} @@ -31,9 +10,9 @@ entry_display.create = function(configuration) local justify = v.right_justify table.insert(generator, function(item) if type(item) == 'table' then - return utils.align_str(entry_display.truncate(item[1], v.width), v.width, justify), item[2] + return strings.align_str(entry_display.truncate(item[1], v.width), v.width, justify), item[2] else - return utils.align_str(entry_display.truncate(item, v.width), v.width, justify) + return strings.align_str(entry_display.truncate(item, v.width), v.width, justify) end end) else |
