Commit Graph

1412 Commits

Author SHA1 Message Date
Guldoman 4d649ba92d
fix: avoid iterating over a changing table in `run_threads` (#1794)
* fix: avoid iterating over a changing table in `run_threads`

This is done to avoid iterating over a table that can change in the meantime.
More precisely the issue appears if a thread is removed from the table, we yield early from `run_threads` because we reached the end of the frame, and a new thread is added before the next iteration.

For example:
```lua
local lost_time = false
core.add_thread(function()
  -- force early yield
  local t0 = system.get_time()
  while system.get_time() - t0 < .1 do end
  lost_time = true
end, "a")

local step = core.step
function core.step()
  if lost_time then
    -- add a new thread while run_threads hasn't finished iterating
    core.add_thread(function()end, "a1")
    lost_time = false
  end
  return step()
end
```
would crash with `invalid key to 'next'`.

* fix: only run coroutine if it wasn't removed

* fix: don't handle `core.threads` table as an array

This caused some entries to be skipped or even removed erroneously.
2024-06-05 08:58:19 -04:00
fgelm01 e0a7bdbcba
Change co_wait to co_await in language_cpp (#1800)
The C++20 keyword is spelled `co_await`.
2024-06-05 12:25:33 +02:00
Guldoman 21dcd782c0
Skip patterns matching nothing in `tokenizer` (#1743)
These patterns cause infinite loops, so warn about them and skip them.
2024-04-15 09:00:03 +08:00
PerilousBooklet 727c179deb
Added Arduino syntax highlighting support alongside C++. (#1767) 2024-04-13 10:54:31 +02:00
PerilousBooklet e9e2d83dc5
Fixed some typos in core.init (#1755)
* Fixed some typos.

* Update data/core/init.lua

Co-authored-by: Takase <20792268+takase1121@users.noreply.github.com>

* Update data/core/init.lua

Co-authored-by: Takase <20792268+takase1121@users.noreply.github.com>

---------

Co-authored-by: Takase <20792268+takase1121@users.noreply.github.com>
2024-03-28 19:33:55 +01:00
Guldoman 3bed5c16ae
Limit `language_js` regex avoidance to numbers, and fix starting `/*` comments (#1744)
* Avoid starting regexes only after numbers in `language_js`

* Allow starting `/*` comments after numbers in `language_js`
2024-03-25 00:20:32 +01:00
Aziz Mazouz Jaber 6e849890be
Add from symbol to support ESM (#1754) 2024-03-24 14:25:44 -04:00
Guldoman cfca01e88e
Fix `language_js` regex/comment distinction (#1731) 2024-03-06 21:06:36 +01:00
Guldoman 2c1dc93d9d
Improve `CommandView` and `autocomplete` scroll behavior (#1732)
* Make command palette item scrolling more natural

Also add a config option for the maximum number of visible entries in the command palette.

* Make `autocomplete` item scrolling more natural
2024-03-05 22:56:01 -05:00
Guldoman abf8955799
Improve `autocomplete` suggestions box behavior (#1734)
* Improve `autocomplete` suggestions box sizing

This avoids that the box gets too big because of non-visible items, and makes it reactive to window sizing.

* Draw ellipsis when `autocomplete` entries aren't fully visible
2024-03-05 22:29:17 -05:00
PerilousBooklet 03b8c239dc
Added .pyi extension to python. (#1728) 2024-02-24 01:46:28 +01:00
Luke aka SwissalpS 8cf40de860
Fix comment typos in data/core/{init.lua,dirwatch.lua} (#1549)
* comment typo in data/core/init.lua

* init.lua reword comment

* Update dirwatch.lua

Some wording is still whacky, maybe next time

* Update dirwatch.lua

* clear up can/may be not nil confusion

* falsey vs falsy new wording to help out

* falsey -> falsy

* Update data/core/dirwatch.lua

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2024-01-21 22:30:59 +01:00
Takase dd69d7b9d0
language_js: support binary and octal representation (#1710) 2024-01-21 10:18:13 +08:00
vqn c561eb78e6
autoreload docs only if their filename matches an actual file (#1698) 2024-01-21 01:49:25 +01:00
vqn fd9b17ff15
reorder nagview options on doc:save error to be more consistent with other nagview confirmations (#1696) 2024-01-20 01:19:12 +01:00
Fiji c27d9aa0c0
Improve number highlighting for python syntax highlighting (#1704)
* Improve number highlighting for python syntax highlighting

Adds support for octal and binary representation, as well uppercase characters (X, B and O)

* add underscore and negative hex/oct/bin value support

* Removed | from pattern
2024-01-20 01:04:49 +01:00
vqn 8b9b26e18f
Fix doc:create-cursor-previous/next-line with tabs (#1697)
* use DocView.translate to split cursor on previous/next line

* use dv.doc instead of doc()
2024-01-13 13:49:26 +01:00
Adam Harrison cfbe68936a Fixed a minor bug, should close issue #1680. 2023-12-03 11:09:56 -05:00
ThaCuber f26eef14fa
fix nagbar failed save message (#1678)
* fix nagbar failed save message

- visually separated statements with a `.`
- first statement slightly rewritten
- use `'` rather than `"`

* yeahhhh no back to `"`
2023-12-03 06:44:07 +08:00
Guldoman e8ae7583bc
Expose plaintext syntax (#1652) 2023-11-30 10:53:01 -05:00
Guldoman 9a4831d5c2
Use `\r\n` for new files on Windows (#1596)
* Use `\r\n` for new files on Windows

* Add `config.line_endings`
2023-11-30 10:51:10 -05:00
Guldoman 5cc8acb082
Improve font/color change detection in `language_md` (#1614)
* Delay setting font for custom `language_md` token types

* Improve font/color change detection in `language_md`
2023-11-29 16:12:22 -05:00
Adam 0e779bba0f
Reverted cursor API to something more compatible with old API. (#1674)
* Reverted cursor API to something more compatible with old API.

* Implemented discord discussion.

* Reduced thiccness of overwrite cursor.
2023-11-29 21:29:37 +01:00
ThaCuber 9615ead41b
Text overwriting (#1495)
* added text overwriting

* rewrote `DocView:draw_caret` to not use the order of draws

* forgot to delete some old code in `DocView:draw_overlay`
also added a temporary solution to overwriting
and added the missing arguments in `DocView:draw_ime_decoration`
and fixed `DocView:draw_caret`

* accidentally broke the `draw_caret` call in `draw_overlay` in the process

* multiline

* fixed calling `Doc:get_char` as a function
that, in turn, crashed the editor because "can't index a number"

* move and rename some stuff

* remove unneeded extra check

I just had to change the `~=` to `<` in the second condition

* overwrite disregards pasting text

* disregard overwrite on selections; doc only removes selection

* Fixed error where `doc` was used, instead of `self`.

---------

Co-authored-by: ThaCuber <70547062+ThaCuber@users.noreply.github.com>
Co-authored-by: Adam Harrison <adamdharrison@gmail.com>
2023-11-29 14:12:43 -05:00
Guldoman e95094f0ca
Fix patterns starting with `^` in `tokenizer` (#1645)
Previously the "dirty" version of the pattern was used, which could 
result in trying to match with multiple `^`, which failed valid matches.
2023-11-29 11:11:46 -05:00
Guldoman 1c10bb894d
Fix `language_js` regex constant detection (#1581)
* Fix `language_js` regex constant detection

* Simplify regex constant detection in `language_js`

* Add more possessive quantifiers in `language_js` regex constant detection

This avoids more catastrophic backtracking cases.

* Allow `.` after regex constant in `language_js`
2023-11-29 11:00:09 -05:00
Guldoman f457bc33fa
Fix editing after undo not clearing the change id (#1574) 2023-11-29 10:45:53 -05:00
Guldoman 5532b52ad8
Fix selecting newlines with `find-replace:select-add-{next,all}` (#1608)
* Avoid adding existing selections in `select_add_next`

* Use the first available selection as delimiter in `select_add_next`

* Fix returning searches with newlines in `search.find`

* Fix repeat search when the last result spanned multiple lines
2023-11-29 10:40:47 -05:00
Guldoman ee93c3b08a
Fix `core.redraw` when window is not focused (#1601)
* Execute at least one step when window has no focus

This way if `core.redraw` is set, it's respected.

* Fully run threads at least once when window has no focus

This allows threads that set `core.redraw` (like `projectsearch`) to 
continue running even after the window loses focus.

"Fully" here means that `run_threads` has gone through *all* the "timed 
out" coroutines at least once.
2023-11-29 10:33:34 -05:00
Guldoman baa0c16e4d
Fix `dirmonitor` sorting issues (#1599)
* Use `PATHSEP` in path-related functions

* Don't stop on digits when getting the common part in `system.path_compare`

* Avoid sorting multiple times in `dirwatch.get_directory_files`

This also fixes the timeout detection in `recurse_pred`.
2023-11-29 09:55:38 -05:00
Guldoman dd75e676bc Fix running `core.step` when receiving an event while not waiting
When `time_to_wake` was <= 0, so when a coroutine needed to be executed 
as soon as possible, we didn't check for events, so we only performed a 
`core.step` with the blink timer.
This resulted in jerky reactions to input.
2023-11-29 09:11:39 +08:00
Daniel Margarido 55a19cd398
Fixed issue with set_target_size passing the wrong value to plugins (#1657)
* Fixed issue with set_target_size passing the wrong value to plugins that are split on the right and activated from the settings UI.

* Added position awareness for the all resize_child_node calls.
2023-11-29 07:34:44 +08:00
Guldoman 921dba3243
Fix deleting indentation with multiple cursors (#1670) 2023-11-28 20:54:11 +01:00
Guldoman 954f60b5f8
Avoid considering single spaces in `detectindent` (#1595) 2023-11-28 20:54:00 +01:00
ThaCuber f4b7cb584f
ease transparency of nagbar dim (#1658)
* ease transparency of nagbar dim

* tiny changes

* lerp alpha rather than the whole color
2023-10-31 16:24:36 -04:00
Guldoman e67ac2818f
Sanitize tab index in `Node:add_view` (#1651)
* Fix `Node:add_view` not adjusting tab index after removing `EmptyView`

* Clamp tab index in `Node:add_view`
2023-10-23 17:58:02 -04:00
Takase 1620a92d54
fix(dirmonitor): deadlock if error handler jumps somewhere else (#1647)
* fix: deadlock if error handler jumps somewhere else

* docs(dirmonitor): fix wrong data type in error callback

* docs(dirmonitor): clarify coroutines and deadlocks

* docs(dirmonitor): wording

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2023-10-21 19:17:49 +02:00
Guldoman 9c6c5475d1
Save in the `workspace` unsaved named files and `crlf` status (#1597)
* Save in the `workspace` unsaved named files

* Save in the `workspace` the `crlf` status and restore it for "new" files
2023-10-18 06:46:58 +02:00
Guldoman 8ccdcb7820
Ignore keypresses during IME composition (#1573)
Some IMEs continue sending keypresses even during composition, so we 
just ignore them.
2023-10-18 06:46:27 +02:00
Guldoman cca1c798d2
Improve `common.serialize` (#1640)
* Make `common.serialize` more locale-independent

* Handle inf/nan numbers in `common.serialize`
2023-10-18 06:45:52 +02:00
Guldoman f69f43c3f5
Mark unsaved named files as dirty (#1598) 2023-10-18 06:45:31 +02:00
Guldoman 57dffbaf2a
Remove DPI detection for default `SCALE`
This often leads to `SCALE` values that are way off, and makes Lite XL 
unusable, so we now just default it to 1.
2023-09-30 16:48:38 +02:00
Guldoman b4e95b865c
Make `linewrapping` consider the expanded `Scrollbar` size
This avoids reflowing the text when hovering the scrollbar.
2023-09-07 04:07:52 +02:00
Guldoman 7e44162101
Fix `Scrollbar.{expanded,contracted}_size` documentation 2023-09-07 04:07:52 +02:00
Robert Hildebrandt 185b9cb080
Fixed C++14 digit separators (#1593) 2023-09-07 01:54:52 +02:00
Takase ac5c65c521
docs(core.config): add documentation for config options (#1512)
* docs(core.config): add documentation for config options

* docs(core.config): remove wrong newline

* docs(core.config): remove trailing whitespace

* docs(core.config): add missing whitespace

* docs(core.config): add disclaimer for core.file_size_limit

* docs(core.config): fix wrong description of the pattern

* docs(core.config): fix wrong description

* docs(core.config): fix wrong description for transitions

* docs(core.config): guide user to drawwhitespace plugin

* docs(core.config): clarify libdecor usage

* docs(core.config): clarify various things

* docs(core.config): clarify more about libdecor support

* docs(core.config): fix missing enum separator

* docs(core.config): remove wayland-specific advice on config.borderless
2023-08-26 11:32:39 -04:00
sammyette 5f68e8b7a9
feat(statusview): make a separate item for doc position percent (#1579)
* feat(statusview): make a separate item for doc position percent

* chore: remove unused variable

* fix(statusview): remove command for percent doc item

* fix(statusview): change doc percent tooltip

* fix(statusview): change percent tooltip message
2023-08-26 11:19:12 -04:00
Jefferson González 215b8daef7
Autocomplete plugin improvements (#1519)
* Add icons support to autocomplete plugin

* Removed redundant flag check

* Added support for non syntax colors

* Assert if color name not in style.syntax

* Autocomplete plugin improvements

* Support suggestion symbols scoping
  - global: all open documents
  - local: current document
  - related: all open documents with same syntax
  - none: language syntax symbols only
* Register style.syntax[] entries as icons
* Other related fixes
2023-08-26 10:50:48 -04:00
Guldoman 3f28557aeb
Add `NaN` guard to `View:update_scrollbar` 2023-08-26 05:11:33 +02:00
Adam cb66d5b9e7
Adds super as a modkey. (#1590)
* Adds super as a modkey.

* Added in super designation for windows.
2023-08-25 14:34:51 -04:00