diff options
| author | Francesco Abbate <francesco.bbt@gmail.com> | 2022-03-14 10:26:40 +0100 |
|---|---|---|
| committer | Francesco Abbate <francesco.bbt@gmail.com> | 2022-03-14 10:27:21 +0100 |
| commit | 7b44242c4fcb981fe8d08ad0a03d7033731700bc (patch) | |
| tree | 7f1a1ddf8524931e502d8b95507208ef30191fb2 | |
| parent | 328201a3dc26c9f34f281f1a4743f3bb0bd2cfd0 (diff) | |
| download | lite-xl-7b44242c4fcb981fe8d08ad0a03d7033731700bc.tar.gz lite-xl-7b44242c4fcb981fe8d08ad0a03d7033731700bc.zip | |
No longer load deleted files from workspace
| -rw-r--r-- | changelog.md | 5 | ||||
| -rw-r--r-- | data/plugins/workspace.lua | 12 |
2 files changed, 13 insertions, 4 deletions
diff --git a/changelog.md b/changelog.md index a32d8d36..2417aab8 100644 --- a/changelog.md +++ b/changelog.md @@ -5,6 +5,11 @@ This files document the changes done in Lite XL for each release. Improve the NagView to scroll long messages and fix problem with mouse click on buttons didn't work. Contributed by @jgmdev. +When loading a project's workspace no longer open views for files which no longer +exists. +More often file were deleted by user or removed because changing commit and there +was no interest opening an empty document for a file that no longer exists. + ### 2.0.5 Revamp the project's user module so that modifications are immediately applied. diff --git a/data/plugins/workspace.lua b/data/plugins/workspace.lua index 1edfbe1e..73b8486f 100644 --- a/data/plugins/workspace.lua +++ b/data/plugins/workspace.lua @@ -107,10 +107,14 @@ local function load_view(t) dv = DocView(core.open_doc()) if t.text then dv.doc:insert(1, 1, t.text) end else - -- we have a filename, try to read the file - local ok, doc = pcall(core.open_doc, t.filename) - if ok then - dv = DocView(doc) + -- we have a filename, try to read the file. + -- proceed to create a view only if the file exists. + local info = system.get_file_info(t.filename) + if info and info.type == "file" then + local ok, doc = pcall(core.open_doc, t.filename) + if ok then + dv = DocView(doc) + end end end -- doc view "dv" can be nil here if the filename associated to the document |
