From 7ac26175f23754c3a62be698bc41faf103f5b5be Mon Sep 17 00:00:00 2001 From: kyazdani42 Date: Sun, 1 Mar 2020 15:00:34 +0100 Subject: [PATCH] clear prompt with normal : and fix file creation --- lua/lib/fs.lua | 7 ++++--- lua/lib/fs_update.lua | 10 ++++++---- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/lua/lib/fs.lua b/lua/lib/fs.lua index 29a17f89..5f81584a 100644 --- a/lua/lib/fs.lua +++ b/lua/lib/fs.lua @@ -20,7 +20,8 @@ end local function print_err(err) if err ~= nil then api.nvim_command('echohl ErrorMsg') - api.nvim_command('echomsg "'..err..'"') + -- remove the \n with string.sub + api.nvim_command('echomsg "'..string.sub(err, 0, -2)..'"') api.nvim_command('echohl None') end end @@ -48,9 +49,9 @@ local function rename(file, new_path) system('mv '..file..' '..new_path) end -local function create(file, folders) +local function create(path, file, folders) if folders ~= "" then system('mkdir -p '..folders) end - if file ~= nil then system('touch ' ..folders..file) end + if file ~= nil then system('touch '..path..folders..file) end end return { diff --git a/lua/lib/fs_update.lua b/lua/lib/fs_update.lua index c4f2c4f4..9d2c99b7 100644 --- a/lua/lib/fs_update.lua +++ b/lua/lib/fs_update.lua @@ -16,12 +16,11 @@ local function input(v) end local function clear_prompt() - api.nvim_command('echo "\r' .. string.rep(" ", 200) .. '\n"') + api.nvim_command('normal :') end local function create_file(path) local new_file = input("Create file: " .. path) - clear_prompt() local file = nil if not string.match(new_file, '.*/$') then @@ -32,11 +31,14 @@ local function create_file(path) local folders = "" if #new_file ~= 0 then for p in string.gmatch(new_file, '[^/]*') do - folders = folders .. p .. '/' + if p and p ~= "" then + folders = folders .. p .. '/' + end end end - create(file, folders) + clear_prompt() + create(path, file, folders) refresh_git() refresh_tree() update_view()