aboutsummaryrefslogtreecommitdiff
path: root/core/args.lua
diff options
context:
space:
mode:
authormitchell <70453897+667e-11@users.noreply.github.com>2020-08-09 09:42:34 -0400
committermitchell <70453897+667e-11@users.noreply.github.com>2020-08-09 09:42:34 -0400
commit1ba7e5fc6ed6c971630a4faf52ea39649a8f0818 (patch)
treea4b18b7dfac9f651503f3f866f217eac156018c0 /core/args.lua
parentbb6fe84b0b04f77d0b3fb1ad53c340e525d5ea65 (diff)
downloadtextadept-1ba7e5fc6ed6c971630a4faf52ea39649a8f0818.tar.gz
textadept-1ba7e5fc6ed6c971630a4faf52ea39649a8f0818.zip
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.
Diffstat (limited to 'core/args.lua')
-rw-r--r--core/args.lua7
1 files changed, 6 insertions, 1 deletions
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