From 1ba7e5fc6ed6c971630a4faf52ea39649a8f0818 Mon Sep 17 00:00:00 2001 From: mitchell <70453897+667e-11@users.noreply.github.com> Date: Sun, 9 Aug 2020 09:42:34 -0400 Subject: When passing a directory as a command line argument, change to it. This allows for running `textadept [projectdir]` and having the open dialogs start from there instead of `_HOME` or some other directory. --- core/args.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'core') diff --git a/core/args.lua b/core/args.lua index 18ef743b..0e6fd2bf 100644 --- a/core/args.lua +++ b/core/args.lua @@ -55,7 +55,12 @@ local function process(arg, no_emit_arg_none) switch.f(table.unpack(arg, i + 1, i + switch.narg)) i = i + switch.narg else - io.open_file(lfs.abspath(arg[i], arg[-1])) + local filename = lfs.abspath(arg[i], arg[-1] or lfs.currentdir()) + if lfs.attributes(filename, 'mode') ~= 'directory' then + io.open_file(filename) + else + lfs.chdir(filename) + end no_args = false end i = i + 1 -- cgit v1.2.3