fix(terminal): clear correctly on windows (#513)

* clear terminal on windows

* adjust clear function for os specific clear command

---------

Co-authored-by: Dominique Haeusler <dominique.haeusler@amcor.com>
This commit is contained in:
Dominique Haeusler 2023-11-27 15:40:06 +01:00 committed by GitHub
parent fb0c365534
commit 0731e99de5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -323,14 +323,18 @@ function Terminal:send(cmd, go_back)
end
end
function Terminal:clear() self:send("clear") end
--check for os type and perform os specific clear command
function Terminal:clear()
local clear = is_windows and "cls" or "clear"
self:send(term)
end
---Update the directory of an already opened terminal
---@param dir string
function Terminal:change_dir(dir, go_back)
dir = _get_dir(dir)
if self.dir == dir then return end
self:send({ fmt("cd %s", dir), "clear" }, go_back)
self:send({ fmt("cd %s", dir), self:clear() }, go_back)
self.dir = dir
end