Commit Graph
1070 Commits
Author SHA1 Message Date
ThaCuberandtakase1121 ce16538903 add a __tostring method to every object (#1534)
* added a stupid __tostring to every object

* moved every __tostring to just after the :extend() call

---------

Co-authored-by: Adam <adamdharrison@gmail.com>
(cherry picked from commit 880e7f1fa1521cdf176f44627a27c901e187058e)
2025-05-18 22:54:38 +08:00
Guldomanandtakase1121 f87617f829 fix: only allow backslash as path separator in Windows in common.path_suggest (#1976) 2024-12-04 13:02:07 +08:00
Takase 451bfacaf5 docview: prevent overscroll when DocView size is less than lh * 2 (#1971) 2024-12-04 13:02:06 +08:00
ThaCuberandtakase1121 9222136070 allow / for path suggestions in all OSes 2024-12-03 08:35:40 +08:00
Guldomanandtakase1121 f6fd438b08 Return state when tokenizing plaintext syntaxes 2024-12-02 15:21:52 +08:00
Takase 7c68b20115 feat(core.emptyview): add name to emptyview (#1569)
* feat(core.emptyview): add name to emptyview

* fix(core.emptyview): set filename to empty
2024-11-27 20:53:34 +08:00
Guldomanandtakase1121 ac4995ee46 Fix multi-type usage in delimited patterns (#1740)
In the "end" pattern we weren't considering the multiple types.
2024-11-27 20:53:34 +08:00
takase1121 cf40e254fe process: migrate arg validation and checking to Lua 2024-11-27 20:53:32 +08:00
takase1121 4bfcd0d16e core/doc: fix wrong table index in Doc:merge_cursors
it was off by 1
2024-06-24 22:29:05 +08:00
Guldomanandtakase1121 71913e1b86 fix(doc): convert Doc:merge_cursors parameter from "selection index" to table index 2024-06-24 22:29:05 +08:00
takase1121 5ba8cfde6d core/rootview: fix dnd multiple folders into dock 2024-06-23 13:09:52 +08:00
Takase ce70fcf5dd macos: support drag-and-drop and default file associations (#1822)
* macos: support drag-and-drop and default file associations

* resources/macos: use LSItemContentTypes to narrow down files

* macos: support opening folders

* rootview: workaround macos weird dnd event timing

* core/rootview: rename variable and refactor if statement
2024-06-23 10:08:08 +08:00
Guldomanandtakase1121 9fb5d299f9 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-23 09:02:46 +08:00
Guldomanandtakase1121 67202c7284 Skip patterns matching nothing in tokenizer (#1743)
These patterns cause infinite loops, so warn about them and skip them.
2024-04-15 09:02:17 +08:00
PerilousBookletandtakase1121 48712a242d 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-04-15 08:49:40 +08:00
takase1121andGuldoman 48aa350a3e 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

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2024-03-23 20:27:47 +08:00
vqnandtakase1121 df12a5dde6 reorder nagview options on doc:save error to be more consistent with other nagview confirmations (#1696) 2024-01-21 14:48:44 +08:00
vqnandtakase1121 2ce8c58bea 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-21 14:40:41 +08:00
ThaCuberandtakase1121 f1bdd840a1 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-29 08:47:05 +08:00
Guldomanandtakase1121 9be5a46a22 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-30 11:39:55 +08:00
Guldomanandtakase1121 b1a647814f Fix editing after undo not clearing the change id (#1574) 2023-11-30 11:39:41 +08:00
Guldomanandtakase1121 8eacca7ae1 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-30 11:39:27 +08:00
Guldomanandtakase1121 19cef97bcd 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-30 11:39:16 +08:00
Guldomanandtakase1121 5c5c77219b 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-30 09:20:34 +08:00
Guldomanandtakase1121 6cd1f96234 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:41:55 +08:00
Adamandtakase1121 3bf3266ca5 Made coroutines make more sense, and fixed a bug. (#1381)
* Made coroutines make more sense, and fixed a bug.

* Fixed typo.

* Additional checking for off-cycles.

* Fixed issue with calling step too much.

* If we have no redraw, set next step time for next frame.

* Added in `now` variables to reduce calls.
2023-11-29 09:41:34 +08:00
Daniel Margaridoandtakase1121 35ef0a9484 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:45:27 +08:00
Guldomanandtakase1121 01cab0611c Fix deleting indentation with multiple cursors (#1670) 2023-11-29 07:41:27 +08:00
TakaseandGuldoman 5d53b13cf4 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-24 20:16:52 +08:00
Guldomanandtakase1121 8c451928bf Ignore keypresses during IME composition (#1573)
Some IMEs continue sending keypresses even during composition, so we 
just ignore them.
2023-10-18 13:14:23 +08:00
Guldomanandtakase1121 a066190ee2 Improve common.serialize (#1640)
* Make `common.serialize` more locale-independent

* Handle inf/nan numbers in `common.serialize`
2023-10-18 13:14:14 +08:00
Guldomanandtakase1121 1ad3b70e9e Mark unsaved named files as dirty (#1598) 2023-10-18 13:14:02 +08:00
Guldomanandtakase1121 316fbbe743 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-10-16 12:04:37 +08:00
Guldomanandtakase1121 397b61e7c6 Fix returned percent when clicking the Scrollbar track 2023-08-26 08:56:35 +08:00
Takase 890e4882f3 fix(core): defer core:open-log until everything is loaded (#1585)
* fix(core): defer core:open-log until everything is loaded

* docs(core): document why core:open-log is opened in a thread
2023-08-26 08:53:05 +08:00
Takase 09dd111c61 docs(core.contextmenu): add documentation for contextmenu (#1567) 2023-08-26 08:52:29 +08:00
Guldomanandtakase1121 3d93e16597 Normalize strokes in fixed order (#1572)
* Use normalized strokes when removing duplicates only when appropriate

* Use normalized stroke in `keymap.unbind`

* Normalize strokes by sorting the modifiers before the keys

This also sorts the modifiers in a fixed manner, decided by 
`modkeys.keys`.
We need to do this because we display the strokes in a few places like 
the command palette.
2023-08-26 08:52:10 +08:00
Guldomanandtakase1121 86cfbe5f3b Make DocView aware of scrollbars sizes (#1177)
* Make `DocView:scroll_to_make_visible` aware of vertical scrollbar width

* Make `DocView` aware of horizontal scrollbar size
2023-08-19 13:31:37 +08:00
Delta-officialandtakase1121 e62a672d7e Normalize stroke before adding keybind (#1334)
* Normalize stroke before adding keybind

* improve normalization algorithm and implement normalization in several functions

Signed-off-by: delta <darkussdelta@gmail.com>

---------

Signed-off-by: delta <darkussdelta@gmail.com>
2023-08-19 13:31:19 +08:00
Takase 5d0bcc99fa Documentation for core.command (#1564)
* docs(core.command): add documentation

* fix(core.common): fix warnings

* docs(core.command): add "core." prefix to all custom types

* docs(core.command); add name as parameter to command.perform

* docs(core.command): fix typo and wording

* docs(core.command): add disclaimer to command.generate_predicate

* docs(core.command): fix wording for predicate

* docs(core.command): document command name

* docs(core.command): document the always_true predicate
2023-08-19 13:30:45 +08:00
TakaseandGuldoman ad0d280ecc Documentation for core.common (#1510)
* docs(core.common): add and improve documentation

* refactor(core.common): remove unused variable to get_height()

* docs(core.common): remove messy newlines

* docs(core.common): fix wording

* docs(core.common): use integer instead of number

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

* docs(core.common): update docs

the docs now follow the style in docs/ directory.
some of the changes suggested are also implemented.

* docs(core.common): fix typo

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

* docs(core.common): restyle annoatations

Extra whitespaces are removed and @overload is used whenever possible.

* docs(core.common): fix various documentation errors

* docs(core.common): simplify unicode description

* docs(core.common): fix return value

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

* docs(core.common): clarify common.bench for not being a benchmark

* docs(common): add disclaimer for numbers in common.serialize

---------

Co-authored-by: Guldoman <giulio.lettieri@gmail.com>
2023-08-19 13:30:45 +08:00
Guldomanandtakase1121 e9678cc140 Skip checking files if no filename was provided to syntax.get 2023-08-19 13:29:48 +08:00
Luke aka SwissalpSandtakase1121 b5617a3eef Fix #1538 log scrolls automatically (the real PR) (#1546)
* fix #1538 log scrolls automatically

adds:
- when user scrolls, position is kept no matter how many new entries
arrive
- when user scrolls up to last entry, autoscroll is enabled again

does not add buttons to jump up/down
see #1538

* move scroll-test out of on_mouse_wheel

* determine diff_index with loop

* remove check at move_towards yoffset

* use while loop instead of repeat loop

* remove meaningless setter

* remove stray var
2023-08-19 13:29:48 +08:00
Luke aka SwissalpSandtakase1121 bd53bc3718 comment typo in object.lua (#1541) 2023-08-19 13:29:48 +08:00
Guldomanandtakase1121 f1f81c8851 Make Doc:sanitize_position return a more appropriate col (#1469)
If `line` is out of range, return the `col` "closest" to the original
values.
2023-08-19 13:28:14 +08:00
Guldomanandtakase1121 68e9c4670e Revert "core syntax: strip the path from filename on syntax.get (#1168)" (#1322)
* Revert "core syntax: strip the path from filename on syntax.get (#1168)"

This reverts commit af6c4bc152.

The previous behavior was correct and allowed access to the full path for path-dependant syntaxes.

* Use `Doc.abs_filename` to obtain syntax when possible

This allows matching full paths in language syntaxes, but we lose the
possibility of matching the project root.
2023-08-19 13:28:14 +08:00
Guldomanandtakase1121 ff884d7d4a When logging don't use core.status_view if not yet initialized 2023-08-19 13:27:31 +08:00
takase1121 c0b1fe348f feat(bootstrap): return error string from C searcher 2023-08-19 12:45:15 +08:00
Guldomanandtakase1121 97f3159415 Merge carets after doc:move-to-{previous,next}-char (#1462) 2023-08-19 12:43:56 +08:00
vqnandtakase1121 f60228f610 #1393 followup (#1463)
* Fix incorrect check in doc:raw_remove

Restore caret position on command doc:cut

* merge cursors and fix new line in clipboard

* add new line to the last copied line
2023-08-19 12:41:57 +08:00