Skip to content

Commit 0bb8b5c

Browse files
Don't replace extension when copying a file (#105)
* Don't replace extension when copying a file * refactor: simplify logic --------- Co-authored-by: Håkon Harnes <[email protected]>
1 parent b32e417 commit 0bb8b5c

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lua/img-clip/paste.lua

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,12 @@ M.paste_image_from_path = function(src_path)
119119
return true
120120
end
121121

122-
local extension = config.get_opt("extension")
122+
local extension = vim.fn.fnamemodify(src_path, ":e")
123+
if extension == "" then
124+
util.warn("File missing extension. Adding png.")
125+
extension = config.get_opt("extension")
126+
end
127+
123128
local file_path = fs.get_file_path(extension)
124129
if not file_path then
125130
util.error("Could not determine file path.")

0 commit comments

Comments
 (0)