Commit graph

675 commits

Author SHA1 Message Date
Michael Davis
4d1f5389f9 Revert "Don't apply transactions to Views in undo/redo"
This reverts commit fd00f3a70e.
2022-11-30 01:15:20 +09:00
Michael Davis
8529d756fa
Remove selections for closed views on all documents (#4888)
Previously we removed selections for a closed view on only the
currently focused document. A view might have selections in other
documents though, so the view needs to be removed from all documents.
2022-11-26 11:52:22 +09:00
Michael Davis
fd00f3a70e Don't apply transactions to Views in undo/redo
View::apply should only be called by EditorView after
42e37a571e. This change removes the
duplicate calls within undo/redo which could cause a panic.
2022-11-24 10:57:12 +09:00
Michael Davis
42e37a571e
Apply transactions to all views (#4733)
* Add a test case for updating jumplists across windows

* Apply transactions to all views on history changes

This ensures that jumplist selections follow changes in documents, even
when there are multiple views (for example a split where both windows
edit the same document).

* Leave TODOs for cleaning up View::apply

* Use Iterator::reduce to compose history transactions

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-11-23 12:28:49 +09:00
Michael Davis
8102c3224f
Limit the number of items in the jumplist (#4750)
Previously, jumplists could grow unchecked. Every transaction is
applied to jumplist selections to ensure that they are up to date
and within document bounds, so this would cause every edit to become
more expensive as jumplist lengths increased throughout a session.
Setting a maximum number of entries limits the cost.

Vim and Neovim limit their jumplists:

* b298fe6cba/src/structs.h (L141)
* e8cc489acc/src/nvim/mark_defs.h (L57)

Notably, Kakoune does not. In Kakoune, changes are applied to jumplist
entries lazily as you hit `<C-o>`/`<C-i>` though, so Kakoune doesn't
have the same growing cost concerns. Kakoune also does not have a
concept of a View which limits the cost further.

Vim and Neovim limit to 100. This seems unreasonably high to me so I've
set this to 30 to start. We can increase if this is problematically
low.
2022-11-22 10:54:50 +09:00
wes adams
19694877aa
When buffer closes, focus on parent buffer (#4766) 2022-11-17 20:53:49 -06:00
Michael Davis
b474ee1843
Factor out common code for focusing the next view (#4607)
There is some common code between Editor::focus_next and Editor::focus
that can be eliminated by refactoring Tree::focus_next into a function
that only returns the next ViewId.
2022-11-17 09:59:59 +09:00
Gaurav Tyagi
91ff903bf3
Add global error/warning count statusline element (#4569) 2022-11-14 19:46:07 -06:00
wes adams
fd585c1ee4
Statusline indicator to show number of selected chars (#4682)
Co-authored-by: wes adams <wadams@grayshift.com>
2022-11-12 11:31:09 -06:00
Doug Kelkhoff
7ed9e9cf25
Dynamically resize line number gutter width (#3469)
* dynamically resize line number gutter width

* removing digits lower-bound, permitting spacer

* removing max line num char limit; adding notes; qualified successors; notes

* updating tests to use new line number width when testing views

* linenr width based on document line count

* using min width of 2 so line numbers relative is useful

* lint rolling; removing unnecessary type parameter lifetime

* merge change resolution

* reformat code

* rename row_styler to style; add int_log resource

* adding spacer to gutters default; updating book config entry

* adding view.inner_height(), swap for loop for iterator

* reverting change of current! to view! now that doc is not needed
2022-11-08 21:19:59 +09:00
Blaž Hrastnik
c94feed83d
core: Move state into the history module 2022-11-08 21:03:54 +09:00
Blaž Hrastnik
c2c1280f02
Resolve a bunch of upcoming clippy lints 2022-11-04 21:06:28 +09:00
Michael Davis
ba394dca6d
Fix panic from two windows editing the same document (#4570)
* Clamp highlighting range to be within document

This fixes a panic possible when two vsplits of the same document
exist and enough lines are deleted from the document so that one of
the windows focuses past the end of the document.

* Ensure cursor is in view on window change

If two windows are editing the same document, one may delete enough of
the document so that the other window is pointing at a blank page (past
the document end). In this change we ensure that the cursor is within
view whenever we switch to a new window (for example with `<C-w>w`).

* Update helix-term/src/ui/editor.rs

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-11-03 15:09:21 +09:00
Charlie Groves
1bed2f3043
Use OSC 52 as a fallback for setting the system clipboard (#3220)
This adds a simple base64 implementation to keep us from adding a crate for one function. It's
mostly based on
a675443d32/src/engine/naive.rs (L42)
2022-11-02 10:12:40 +09:00
dependabot[bot]
e5319ea8c5
build(deps): bump once_cell from 1.15.0 to 1.16.0 (#4548)
Bumps [once_cell](https://github.com/matklad/once_cell) from 1.15.0 to 1.16.0.
- [Release notes](https://github.com/matklad/once_cell/releases)
- [Changelog](https://github.com/matklad/once_cell/blob/master/CHANGELOG.md)
- [Commits](https://github.com/matklad/once_cell/compare/v1.15.0...v1.16.0)

---
updated-dependencies:
- dependency-name: once_cell
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2022-10-31 19:31:08 -05:00
A-Walrus
c4d7cde6c8
Allow the area to be bigger than u16 (width and height remain u16) (#4318)
Now the editor can fill **very** large terminals.
Changed/removed tests which check the truncating behaviour.
2022-10-26 12:00:13 +09:00
James O. D. Hunt
ac0fe29867
commands: Make no arg ':theme' show name (#3740)
Most commands that accept an argument show their current value if no
argument is specified. The `:theme` command previously displayed an
error message in the status bar if not provided with an argument:

```
Theme name not provided
```

It now shows the current theme name in the status bar if no argument is
specified.

Signed-off-by: James O. D. Hunt <jamesodhunt@gmail.com>

Signed-off-by: James O. D. Hunt <jamesodhunt@gmail.com>
2022-10-26 11:59:50 +09:00
Blaž Hrastnik
511d9d8a52
cargo fmt 2022-10-21 13:26:22 +09:00
Charlie Groves
7e29ee6dae
Autosave all when the terminal loses focus (#3178)
* Autosave all when the terminal loses focus

* Correct comment on focus config

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>

* Need a block_try_flush_writes in all quit_all paths

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-10-21 10:35:02 +09:00
Kirawi
ce399471f0
simplify encoding test macro (#4385) 2022-10-21 09:58:13 +09:00
Skyler Hawthorne
6a0b450f55
Fix multi byte auto pairs (#4024)
* Fix test::print for Unicode

The print function was not generating correct translations when
the input has Unicode (non-ASCII) in it. This is due to its use of
String::len, which gives the length in bytes, not chars.

* Fix multi-code point auto pairs

The current code for auto pairs is counting offsets by summing the
length of the open and closing chars with char::len_utf8. Unfortunately,
this gives back bytes, and the offset needs to be in chars.

Additionally, it was discovered that there was a preexisting bug where
the selection was not computed correctly in the case that the cursor
was:

1. a single grapheme in width
2. this grapheme was more than one char
3. the direction of the cursor is backwards
4. a secondary range

In this case, the offset was not being added into the anchor. This was
fixed.

* migrate auto pairs tests to integration

* review comments
2022-10-21 09:22:20 +09:00
Matouš Dzivjak
e25af1f744
feat(view): re-use align_view function (#4390) 2022-10-20 18:53:05 -05:00
Matouš Dzivjak
4cff625054
chore(view): remove indent_unit helper fn (#4389) 2022-10-20 17:05:04 -05:00
Blaž Hrastnik
78c0cdc519
Merge pull request #2267 from dead10ck/fix-write-fail
Write path fixes
2022-10-20 23:11:22 +09:00
Blaž Hrastnik
418a622db9
Merge pull request #4061 from pascalkuthe/undercurl-modifier
Support different kinds of underline rendering (updated)
2022-10-19 13:51:13 +09:00
Skyler Hawthorne
9a406b569b reduce LSP timeout to 3s 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
759d55cc81 fail if doc save sender is closed 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
e645804b0a Editor::flush_writes returns an error 2022-10-18 22:31:39 -04:00
Blaž Hrastnik
2a43ee0164 doc.close() now unused 2022-10-18 22:31:39 -04:00
Blaž Hrastnik
1b6f7319cd Wire up save_queue as a part of new_document rather than open 2022-10-18 22:31:39 -04:00
Blaž Hrastnik
b155e861ad Use a write_count to determine how many writes left to flush 2022-10-18 22:31:39 -04:00
Blaž Hrastnik
b0212b3611 Deduplicate flush_writes 2022-10-18 22:31:39 -04:00
Blaž Hrastnik
30c93994b5 Use a single save_queue on the editor 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
31d1bbfddb review comments 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
9e64974f13 remove Document::format_and_save 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
af03df3413 fix write scratch buffer to file 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
18c32118b1 Save text in document saved events, use in status message 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
f82a551b98 Rename doc save event names to past tense 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
7b11e9ac69 fix erroneous write sender close
This was not distinguishing the error types when trying a receive on an empty
receiver, which was erroneously causing the sender to be closed when trying to
flush the writes when there were none
2022-10-18 22:31:39 -04:00
Skyler Hawthorne
faa00d4cc3 increase LSP shutdown timeout
The Clang LAP takes a long time to shut down on Windows
2022-10-18 22:31:39 -04:00
Skyler Hawthorne
c9418582d2 fix modified status with auto format 2022-10-18 22:31:38 -04:00
Skyler Hawthorne
cb23399dee improve reliability of shutdown 2022-10-18 22:31:38 -04:00
Skyler Hawthorne
e1f7bdb1d2 fix buffer-close 2022-10-18 22:31:38 -04:00
Skyler Hawthorne
83b6042b97 fix(write): do not set new path on document until write succeeds
If a document is written with a new path, currently, in the event that
the write fails, the document still gets its path changed. This fixes
it so that the path is not updated unless the write succeeds.
2022-10-18 22:31:38 -04:00
Skyler Hawthorne
a5a93182cd fix: buffer-close ensuring writes
Make sure buffer-close waits for the document to finish its writes.
2022-10-18 22:31:38 -04:00
Skyler Hawthorne
d706194597 chore(write): serialize write operations within a Document
The way that document writes are handled are by submitting them to the
async job pool, which are all executed opportunistically out of order. It
was discovered that this can lead to write inconsistencies when there
are multiple writes to the same file in quick succession.

This seeks to fix this problem by removing document writes from the
general pool of jobs and into its own specialized event. Now when a
user submits a write with one of the write commands, a request is simply
queued up in a new mpsc channel that each Document makes to handle its own
writes. This way, if multiple writes are submitted on the same document,
they are executed in order, while still allowing concurrent writes for
different documents.
2022-10-18 22:31:38 -04:00
A-Walrus
2c36e33e0a Make skip_levels a u8 2022-10-18 00:38:16 +09:00
A-Walrus
3ba665d804 Fix rendering of lines longer than 2^16
Before things would be cast to u16 earlier than needed, which would
cause problems for insanely long lines (longer than 2^16 ~ 65 thousand)
2022-10-18 00:38:16 +09:00
Filip Dutescu
2457111bf0
feat(csharp,debug): add C# debugger support (#4213) 2022-10-15 15:33:57 -05:00
Pascal Kuthe
66a49080bc
merge underline-style and underline-color into a single table 2022-10-13 19:03:58 +02:00