From 664b3ee8b72ef815227b9f1fd76ee0ca72f3704a Mon Sep 17 00:00:00 2001 From: Kelsey Judson Date: Mon, 1 Jan 2018 19:52:40 +1300 Subject: vis-open: fix for absolute and non-existent paths When the shell cannot find any matching files, the glob is not expanded, and vis-open will return the absolute path of the current working directory (because dirname outputs '.'), followed by the filename, followed by a literal '*'. This commit checks that the final path actually exists, and if not, exits with status 1. It also uses text_object_longword for the range to match, so that absolute paths are accepted, and replaced properly (else it only works back to the first '/'). --- lua/plugins/complete-filename.lua | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lua') diff --git a/lua/plugins/complete-filename.lua b/lua/plugins/complete-filename.lua index cb5b361..98e8ec3 100644 --- a/lua/plugins/complete-filename.lua +++ b/lua/plugins/complete-filename.lua @@ -6,7 +6,7 @@ vis:map(vis.modes.INSERT, "", function() local pos = win.selection.pos if not pos then return end -- TODO do something clever here - local range = file:text_object_word(pos > 0 and pos-1 or pos); + local range = file:text_object_longword(pos > 0 and pos-1 or pos); if not range then return end if range.finish > pos then range.finish = pos end if range.start == range.finish then return end @@ -29,7 +29,8 @@ vis:map(vis.modes.INSERT, "", function() local file = win.file local pos = win.selection.pos if not pos then return end - local range = file:text_object_word(pos > 0 and pos-1 or pos); + -- TODO do something clever here + local range = file:text_object_longword(pos > 0 and pos-1 or pos); if not range then return end if range.finish > pos then range.finish = pos end local prefix = file:content(range) -- cgit v1.2.3