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 '/'). --- vis-lua.c | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'vis-lua.c') diff --git a/vis-lua.c b/vis-lua.c index 3c998e7..124e380 100644 --- a/vis-lua.c +++ b/vis-lua.c @@ -2234,6 +2234,14 @@ static int file_mark_get(lua_State *L) { * @treturn Range range the range */ +/*** + * WORD text object. + * + * @function text_object_longword + * @tparam int pos the position which must be part of the word + * @treturn Range range the range + */ + static int file_text_object(lua_State *L) { Filerange range = text_range_empty(); File *file = obj_ref_check(L, 1, VIS_LUA_TYPE_FILE); @@ -2703,6 +2711,7 @@ void vis_lua_init(Vis *vis) { const char *name; } textobjects[] = { { VIS_TEXTOBJECT_INNER_WORD, "text_object_word" }, + { VIS_TEXTOBJECT_INNER_LONGWORD, "text_object_longword" }, }; for (size_t i = 0; i < LENGTH(textobjects); i++) { -- cgit v1.2.3