Skip to content

Commit 52abb46

Browse files
committed
for #362
1 parent 81fdfe6 commit 52abb46

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

lua/easycomplete/cmdline.lua

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,16 @@ this.REG_CMP_HANDLER = {
244244
return {}
245245
else
246246
local result = vim.fn.getcompletion("", cmp_type)
247+
-- Hack for file and file_in_path
248+
-- getcompletion 的路径结果中,给所有的当前目录加上./前缀
249+
-- 便于连续回车匹配
250+
if cmp_type == "file" or cmp_type == "file_in_path" then
251+
for i, item in ipairs(result) do
252+
if string.find(item, "^[^/]+/$") ~= nil then
253+
result[i] = "./" .. item
254+
end
255+
end
256+
end
247257
return result
248258
end
249259
end
@@ -252,7 +262,8 @@ this.REG_CMP_HANDLER = {
252262
-- 输入路径
253263
pattern = {
254264
"^[a-zA-Z0-9_]+%s+.*/$",
255-
"^[a-zA-Z0-9_]+%s+.*/[a-zA-Z0-9_]+$"
265+
"^[a-zA-Z0-9_]+%s+.*/[a-zA-Z0-9_]+$",
266+
"^[a-zA-Z0-9_]+%s+/$"
256267
},
257268
get_cmp_items = function()
258269
return this.get_path_cmp_items()
@@ -269,6 +280,13 @@ end
269280

270281
function this.get_path_cmp_items()
271282
local typing_path = vim.fn['easycomplete#sources#directory#TypingAPath']()
283+
-- 取根目录
284+
-- insert模式下为了避免和输入注释"//"频繁干扰,去掉了根目录的路径匹配
285+
-- 这里不存在这个频繁干扰的问题,再加回来
286+
if string.find(typing_path.prefx,"%s/$") ~= nil then
287+
typing_path.is_path = 1
288+
end
289+
console(typing_path)
272290
if typing_path.is_path == 0 then
273291
return {}
274292
else

0 commit comments

Comments
 (0)