Commit Graph

110 Commits

Author SHA1 Message Date
Guldoman b1a647814f
Fix editing after undo not clearing the change id (#1574) 2023-11-30 11:39:41 +08:00
Guldoman 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
Guldoman 1ad3b70e9e
Mark unsaved named files as dirty (#1598) 2023-10-18 13:14:02 +08:00
Guldoman e9678cc140
Skip checking `files` if no filename was provided to `syntax.get` 2023-08-19 13:29:48 +08:00
Guldoman 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
Guldoman 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
vqn 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
vqn 12e0634f9c
fix cursors positions when deleting multiple selections (#1393)
* correctly handle overlapping selections merge cursors in Doc:raw_remove
2023-08-19 12:39:33 +08:00
Guldoman 6d217204f6
Allow `tokenizer` to pause and resume in the middle of a line (#1444) 2023-08-19 12:39:22 +08:00
Jefferson González 9c7304f555
highlighter: autostop co-routine when not needed (#881)
* highlighter: autostop co-routine when not needed

* applied @Guldoman suggestions
2022-11-06 03:38:10 +01:00
Guldoman b029f5993e
Don't sort in `Doc:get_selection_idx` with an invalid index 2022-11-02 21:11:41 +01:00
Guldoman 0f160e614e
Improvements to multicursor copy/paste (#1123)
* Add `Doc:get_selection_idx`

* Make multicursor paste add a cursor at the end of each paste

* Better manage paste of multicursor whole line copy

* Document `Doc:get_selection_idx`

* Keep track of last added selection in `Doc`

* Make use of `doc.last_selection` in `Doc` commands

* Make `Doc:get_selection` return the `Doc.last_selection` if possible
2022-11-01 18:16:39 -04:00
Guldoman 5c2c95765e
Add IME support (#991) 2022-10-15 19:58:51 -04:00
Guldoman e7c4bdfe8e
Make `Doc:get_selection[s]` return if the selection was actually sorted 2022-07-11 05:39:55 +02:00
Guldoman d6ce9e1ac6
Don't indent empty lines in a selection 2022-06-25 03:32:47 +02:00
Guldoman 685956cbdb
Add `Highlighter:update_notify` to keep track of retokenized lines
This is helpful for plugins that need to know when a line has been 
retokenized.
2022-06-11 06:21:55 +02:00
jgmdev 3f206db69a initial documentation for better code completion 2022-06-07 22:09:34 -04:00
Adam Harrison 173370694e Split out reload functionality to actual document, and added in a thread to check the document, in the cases where it wouldn't be covered by dirwatch. 2022-05-15 15:24:17 -04:00
Guldoman f92f56d42e
Manage return values from "replacer" function in `Doc:replace`
Before the addition of multi-cursor support, we just returned the second 
return value of the "replacer" function to the caller.

With the introduction of multi-cursors, we naively summed the second 
return values for each cursor.
In some cases the "replacer" function doesn't return any second value, 
so we tried to do math with `nil`, thus throwing errors.

Now the second return value is added to a table which is then returned 
to the caller.
2022-04-27 21:53:35 +02:00
Guldoman 9763701cbf Reset syntax when a filename is provided 2022-03-18 00:36:25 -04:00
Adam Harrison 82325b6a08 Fixed a bunch of problems. Fixed left+click not allowing for square selections, fixed esc not exiting multicursor mode, and allowed cntrl+click to remove a cursor. 2022-03-17 16:55:52 -04:00
Francesco Abbate f6a0e12e31 Merge branch 'master-2.0' 2022-01-19 20:31:33 +01:00
Francesco Abbate fd074ff39a Fix problem when opening project's module document
It wasn't fine to call core.open_doc without filename argument
and later call Doc:save without providing both the filename and
the absolute filename. It was giving a Doc in an inconsistent
status where self.filename was set but not self.abs_filename.
Added an asset to detect early the problem if ever happens again.

In turn the problem prevented the project's module hook to work if the
file was newly created.
2021-12-30 15:26:40 +01:00
Jipok 4a563ddea1 Delete old forgotten self.cursor_clipboard 2021-12-10 19:23:49 +05:00
Jipok 4eee123eff Make cursor_clipboard globa, not per doc 2021-12-08 17:34:10 +05:00
Jipok acc7ceefd4 Correct paste after 'Cut/copy whole line' 2021-12-06 17:59:49 +05:00
Adam a607ef95f9
Merge pull request #682 from Guldoman/indent_refactor
Refactor how to get the indentation of a `Doc`
2021-11-27 11:55:36 -05:00
Adam Harrison 64f66e5d1e Added in cut, copy and paste to the context menu. Also removed find pattern, as that's no longer a valid command. Also made it so commands only show up if their predicates are valid. 2021-11-23 21:03:38 -05:00
Adam Harrison 96db380c73 Manual merge of into . 2021-11-23 15:57:22 -05:00
Adam 43a6e21135
Merge pull request #681 from Guldoman/prepopulate_highlighter
Prepopulate highlighter
2021-11-23 15:38:20 -05:00
Guldoman 23a0f6ca79
Speed up highlighter notify
Avoid calling `table.{insert,remove}` multiple times, as this causes 
multiple shifts in the `self.lines` table.
2021-11-22 06:23:16 +01:00
Guldoman 3d9901695b
Use the new `Doc:get_indent_info` throughout `core` 2021-11-20 04:37:15 +01:00
Guldoman b77b1c0221
Add `Doc:get_indent_info`
It returns the indentation type, size and confirmation status, used by 
the `Doc`.
2021-11-20 04:36:58 +01:00
Guldoman d0a2c913f5
Pre-populate the highlighter
This avoids problems with calls to `[insert,remove]_notify` on lines 
that the highlighter has not yet added.
2021-11-20 01:18:37 +01:00
Guldoman f24aa64cd5
Add `soft_reset` to highlighter
This allows clearing the `lines` table without removing entries.
2021-11-20 01:15:13 +01:00
Takase 8e6f594790
Merge branch 'master' into replace-unpack 2021-11-17 08:42:08 +08:00
Adam 286183f917
Merge pull request #634 from Guldoman/fix_highlighter_holes
Don't insert `nil` in highlighter lines table
2021-11-04 20:45:03 -04:00
Guldoman 9e721937af
Don't insert `nil` in highlighter lines table
When `highlighter:insert_notify` was called, a hole in the array was 
created.
If another call to `highlighter:insert_notify` happened before the hole 
was filled, a `Position out of bounds` error could have been raised.
2021-10-26 00:12:16 +02:00
Guldoman 92db048e7c
Use plain search by default in `search.find` 2021-10-25 00:18:20 +02:00
Francesco 228d6ff101
Merge pull request #466 from Guldoman/new_not_dirty
Avoid setting a new file as dirty if it is empty
2021-10-10 10:05:19 +02:00
Guldoman 3a1274fd08
Merge reverse find functions for lua patterns and regexes 2021-10-10 01:11:41 +02:00
Guldoman cfe0c79a04
Simplify reverse search
Remove `plain_rfind` optimization.
2021-10-10 01:11:40 +02:00
Guldoman 56eace627a
Add reverse option to `search.find` 2021-10-10 01:10:47 +02:00
Francesco Abbate 92362586df Improve highlither for document edits
The syntax highlighter keep a cache of the documents like tokenization.

In order to minimize the amount of tokenize re-computations we insert some
emtty lines or remove some lines in the highlither lines corresponding to
the lines added or removed to the document.
2021-10-08 21:28:27 +02:00
Francesco Abbate 7a435a568a Fix error in incremental syntax highlighter
In the highlither thread We should accept a previously generated line tokenization
past first_invalid_line only if the text is the same. The text can change because of
insert or remove operations.

Close #573.
2021-10-08 21:27:57 +02:00
Francesco Abbate 44d7f3738f Improve highlither for document edits
The syntax highlighter keep a cache of the documents like tokenization.

In order to minimize the amount of tokenize re-computations we insert some
emtty lines or remove some lines in the highlither lines corresponding to
the lines added or removed to the document.
2021-10-07 19:19:08 +02:00
Francesco Abbate 8477818c96 Fix error in incremental syntax highlighter
In the highlither thread We should accept a previously generated line tokenization
past first_invalid_line only if the text is the same. The text can change because of
insert or remove operations.

Close #573.
2021-10-07 19:03:16 +02:00
Guldoman db3643653e
Sanitize selections after redo 2021-10-02 22:03:52 +02:00
Guldoman 0a52861129 Revert horizontal scroll implementation 2021-09-08 07:11:50 +02:00
Guldoman a920e5b0e6
Avoid setting a new file as dirty if it is empty 2021-08-31 23:16:02 +02:00