From 6b23ef988b0f469917ede79c8a61c31456d0a8b0 Mon Sep 17 00:00:00 2001 From: Rui Marques Date: Tue, 22 Sep 2020 22:38:38 +0200 Subject: [PATCH] Fix issue with trimming path separator '/' --- lua/telescope/make_entry.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lua/telescope/make_entry.lua b/lua/telescope/make_entry.lua index 4db664e..ede729b 100644 --- a/lua/telescope/make_entry.lua +++ b/lua/telescope/make_entry.lua @@ -212,7 +212,12 @@ function make_entry.gen_from_buffer(opts) -- if bufname is inside the cwd, trim that part of the string if bufname:sub(1, #cwd) == cwd then - bufname = bufname:sub(#cwd + 1, #bufname) + local offset = 0 + -- if cwd does ends in '/', we need to take it off + if cwd:sub(#cwd, #cwd) ~= '/' then + offset = 1 + end + bufname = bufname:sub(#cwd + 1 + offset, #bufname) end local position = get_position(entry)