diff options
| author | tami5 <65782666+tami5@users.noreply.github.com> | 2021-09-20 12:52:59 +0300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-09-20 12:52:59 +0300 |
| commit | 60660334c70d9d81dccc10a563e01920b9455e76 (patch) | |
| tree | 856d8503c209e4c9079b3e64df0b966f21db2ed0 /lua/telescope/utils.lua | |
| parent | f0db7d3a5997cbd7e60638a071c1b661a854dfc6 (diff) | |
feat(defaults): enable customization of path_display.truncate (#1264)
followup to https://github.com/nvim-telescope/telescope.nvim/pull/1254
and implementation of
https://github.com/nvim-telescope/telescope.nvim/pull/1254#issuecomment-922527270
Diffstat (limited to 'lua/telescope/utils.lua')
| -rw-r--r-- | lua/telescope/utils.lua | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/lua/telescope/utils.lua b/lua/telescope/utils.lua index f145184..f19e973 100644 --- a/lua/telescope/utils.lua +++ b/lua/telescope/utils.lua @@ -329,9 +329,10 @@ local is_uri = function(filename) return string.match(filename, "^%w+://") ~= nil end -local calc_result_length = function() +local calc_result_length = function(truncate_len) local status = get_status(vim.api.nvim_get_current_buf()) - return vim.api.nvim_win_get_width(status.results_win) - status.picker.selection_caret:len() - 2 + local len = vim.api.nvim_win_get_width(status.results_win) - status.picker.selection_caret:len() - 2 + return type(truncate_len) == "number" and len - truncate_len or len end utils.transform_path = function(opts, path) @@ -371,7 +372,7 @@ utils.transform_path = function(opts, path) end if vim.tbl_contains(path_display, "truncate") or path_display.truncate then if opts.__length == nil then - opts.__length = calc_result_length() + opts.__length = calc_result_length(path_display.truncate) end transformed_path = truncate(transformed_path, opts.__length, nil, -1) end |
