* fix delete_temp_files() deleting in EXEDIR but temp_filename() was
creating temp files in USERDIR
* make delete_temp_files() public so it can be used by plugins
* add optional `dir` parameter to both delete_temp_files() and
temp_filename() to allow specifying a different directory, this is
for example useful when generting markdown previews, the temp file
should be generated in the project dir in case the readme references
images that are relative to it, so the web browser can find them.
This new config flag ignores the plugins version check at startup
which helps a lot when working on new or old plugins that doesn't match
the mod or lite-xl version and you still desire to load them to fix them
by checking with lite-xl it self which errors need to be corrected.
When a user modifies and saves the init.lua or a project module file the
reload_customizations() function was performing unnecessary reloading
of core.config and core.style. This resulted on the replacement of config
tables with new tables, breaking all active references been used by
the consumers of this config options. Been redundant this means
that every consumer was using its own copy of a configuration table
different from the one referenced on core.config and user changes not
taking place.
* Fixed some issues with inotify and multiple events at the same time. Seems to be working now.
* Cleaned up and simplified function, and commented, and fixed a number of bugs.
* Simplifying and fixing further.
* Improved performance for skipping large amounts of files.
* Added in extra checks, and changed paths. We should probably unify these path styles.
* Fixed stutter.
* Removed extraneous functions.
* Cleaned up more, added more testing; dealt with multiple sequential events correctly.
Removed dmon, and replaced with logic that works across Linux, Mac, FreeBSD and Windows. Have tested on all platforms, and seems to work.
Co-authored-by: Jan200101 <sentrycraft123@gmail.com>
The pattern cannot be tested in advance as it seems that Lua inspect
the pattern only partially, the part that is actually used.
We resort to use pcall to catch any error when using the pattern.
Evolve the rule for directory in ignore_files to be more natural
and easy to understand.
When a final '/' or '/$' is found we consider the pattern to match
a directory and the pattern is not modifed. In turns, is used, before
matching a directory's name a final '/' is appended to its name
before checking if it matches the pattern.
With the previous rule a final '/' in the pattern meant also a directory
but the '/' was removed from the pattern.
When a user's or project's module configuration file is changed we
make sure that the config.plugins fields are all restored so that
all plugins already loaded can continue to work.
Some asserts are placed in case that can effectively occur
so we remove the assertion and we return false. In turn we
adapt the logic accordingly so when false is returned to add
a watch we do not open that directory.
Works correctly and the logic seems sound even if somewhat quirky.
`^%.` match any file of directory whose basename begins with a dot.
`^/node_modules$/"` match a directory named `node_modules` at the project's root.
Note that the final '/' needs to be at the end. The '/' after the '^' needs to be there to trigger
a match of the full path filename so we are sure it is at the root.
PROBLEM: the '/' to trigger full path match could be in a pattern's special expression like:
[^/]
`^%.git$/` match any directory name '.git' anywhere in the project.
`^/%.git$/` match a directory named '.git' only at the project's root.
`^/subprojects/.+/` match any directory in a top-level folder named "subprojects".
`^/build/` match any top level directory whose name begins with "build"
PROBLEM: may be surprising, one may expects it matches only a directory named 'build'. It actually acts like
it was `^/build.*/`.
For special file types like the ones in /dev/ the info
entry's type is neither file neither dir.
We prevent these kind of files from being listed in the
project.
Avoid reloading the core.keymap module when user's config
or project module change.
The reason is the plugins like autocomplete can add keymaps
and the additions from plugins would be lost.
Close issue #793
There was a double error because the config.ignore_files was
used at two differect places in different ways.
Now we apply coherently the original rule to apply
config.ignore_files to the basename of each file or directory.
Simplifies and uniformize the logic on the Lua side for the
setting of directories' watches. Now we always use the methods:
systems.watch_dir_add / rm
on all the project's directories at any depth when we are not
in files limit mode.
In files limited mode the functions systems.watch_dir_add/rm are
called only on the expanded folders. The shown_subdir table is also
updated only in files limited mode.
On the C side, using the dmon library, we remove the recursive argument
from the system.watch_dir and we always call it recursively except on
Linux. At the same time the functions:
systems.watch_dir_add / rm
are provided but as dummy functions that does nothing except on Linux
where they work as before to add / remove sub-directories in the inotify
watch.
In this was on the Lua side we always act we if the watches needed to be
set for each sub-directory explicitly, independently of the system.
The important improvement introduced is that we always avoid calling
dmon_watch recursively on Linux. This latter thing is problematic with
inotify and is therefore avoided on Linux.
On the other side we simplifies the logic on the Lua side and remove
conditions based on the OS used.
Changes in project's module required an application restart to work.
Now the project will be re-scanned when the project's module changes.
In addition ensure borderless window config is changed when changed
in user's preferences.
It is not a good practice to keep a reference to the project's
directory object outside of the "core" module itself.
The TreeView was using such a reference in the cache item for each
file or directory entry. Replace the reference to the object with
the absolute name of the project directory.
Address issue:
https://github.com/lite-xl/lite-xl/issues/689
Attempt to provide a more accurate fix to commit:
59f64088e1
For this latter what happens is that any change inside a directory
cause the corresponding entry to be folded in the TreeView.
The new change is more accurate because we remove only the stale
entry corresponding to the delete event and we do not reset the
cache of the parent directory using the modify event.
Fix a conspicuous omission to call the dmon_unwatch function
when changing project directory.
This uncovered a bug or a quirk of the dmon library where the watch_ids
can change as a result of calling dmon_unwatch because they are just
indexes on a contiguous array. Use a workaround to always unwatch the
first valid watch_id N times.
Address issue:
https://github.com/lite-xl/lite-xl/issues/689
Attempt to provide a more accurate fix to commit:
59f64088e1
For this latter what happens is that any change inside a directory
cause the corresponding entry to be folded in the TreeView.
The new change is more accurate because we remove only the stale
entry corresponding to the delete event and we do not reset the
cache of the parent directory using the modify event.
The function "file_search" in core.init was sometimes giving a wrong index
value, off by one.
The problem happened for example when the entry to search was "less than"
the first entry, the function returned a value of two instead of one as
expected.
The bug was easily observed creating a new directory with a name that comes
as the first in alphabetical order within the project.
The function "file_search" in core.init was sometimes giving a wrong index
value, off by one.
The problem happened for example when the entry to search was "less than"
the first entry, the function returned a value of two instead of one as
expected.
The bug was easily observed creating a new directory with a name that comes
as the first in alphabetical order within the project.
When adding a directory in a project we check if the filesystem is too
slow. If it is too slow we act as if the projects was files-limited by
the number of files but we show a specific warning.
This solution is not perfect but for very low filesystem it can limit
the problem. Otherwise the application would be totally irresponsive.
Use the function defined in the "common" module.
Move the check for not-nil filename from common.normalize_path
to core.open_doc. In this latter the filename can be nil if a
new unnamed document is created.
Move the function mkdirp into common to be generally available.
Use the new common.mkdirp from create_user_directory() from
core/init.lua replacing previous parent directory creation code
within the function.
The previous mkdirp function did not work on Windows where
absolute paths starts with a drive letter. The code from
create_user_directory() did not have this problem but was wrong
in the way it was creating the nested directories.
The new implementation in common.mkdirp fix both problems.