Closes#11351
Also fixed some minor issues related to log
message contents, and removed unnecessary use
of `.as_mut()` as per code review comments on
the PR.
* don't use backup files with hardlinks
* check if the inodes remain the same in the test
* move funcs to faccess and use AsRawHandle
* use a copy as a backup for hardlinks
* delete backup after copy
In the case of network file systems, if the server time is ahead
of the local system time, then helix could annoy with messages
that the file has already been modified by another application.
These changes are ported from
<https://redirect.github.com/helix-editor/helix/pull/9801>. It's a
cleanup of `Document::apply_impl` that uses some early returns to
reduce nesting and some reordering of the steps. The early returns
bail out of `apply_impl` early if the transaction fails to apply or
if the changes are empty (in which case we emit the SelectionDidChange
event). It's a somewhat cosmetic refactor that makes the function easier
to reason about but it also makes it harder to introduce bugs by mapping
positions through empty changesets for example.
Co-authored-by: Pascal Kuthe <pascalkuthe@pm.me>
* replicate t-monaghan's changes
* remove View.offset in favour of Document.view_data.view_position
* improve access patterns for Document.view_data
* better borrow checker wrangling with doc_mut!()
* reintroduce ensure_cursor_in_view in handle_config_events
since we sorted out the borrow checker issues using partial borrows,
there's nothing stopping us from going back to the simpler implementation
* introduce helper functions on Document .view_offset, set_view_offset
* fix rebase breakage
This commit brings the text decoration API inline with the
LineAnnotation API (so they are consistent) resulting in a single
streamlined API instead of multiple ADHOK callbacks.
This introduces a custom URI type in core meant to be extended later
if we want to support other schemes. For now it's just a wrapper over a
PathBuf. We use this new URI type to firewall `lsp::Url`. This was
previously done in 8141a4a but using a custom URI type is more flexible
and will improve the way Pickers handle paths for previews in the child
commit(s).
Co-authored-by: soqb <cb.setho@gmail.com>
* Add changes before insert mode undo
Fixes#11077
* Address edge cases for undo like Kakoune does
---------
Co-authored-by: Kaniel Kirby <pirate7007@runbox.com>
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
Saving while in insert mode causes issues with the modification
indicator and this is very easy to reproduce with the current state of
the auto-save hook. We can tweak the hook slightly to await the mode
switch out of insert mode to perform the save.
The debounce is preserved: if you save and then immediately exit insert
mode the debounce will be respected. If the debounce lapses while you
are in insert mode, the save occurs as you switch out of insert mode
immediately.
* Implement check before adding path to files
* fix problem where directories were removed from args.files
* Revert "Implement check before adding path to files"
This reverts commit c123944d9b2e125cc0e17e61d53aaffe09234baf.
* Dissallow opening of irregular non-symlink files
* Fixed issue with creating new file from command line
* Fixed linting error.
* Optimized regularity check as suggested in review
* Created DocumentOpenError Sum Type to switch on in Application
* Forgot cargo fmt
* Update helix-term/src/application.rs
Accept suggestion in review.
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Moved thiserror version configuration to the workspace instead of the individual packages.
---------
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
* Fix jump_backwards behaviour when jumplist is at capacity
* Decrement self.current while popping from front
* Fix issue with conflicting updates to self.current
* Realised that truncate is intentional
* Use saturating_sub when decrementing current
* Fix naming of previous jump, and remove unneeded comment change
* Remove unnecessary changes in push
* Return num elements removed from front, and use in backward method
* Hide num_removed from public interface and tidy up jump location check
* auto save after delay
* configable
* clearer names
* init
* working with some odd behaviour
* working with greater consistency
* Apply reviewer suggestions
- Remove unneccessary field
- Remove blocking save
* Improve auto-save configuration
Auto save can be configured to trigger on focus loss:
```toml
auto-save.focus-lost = true|false
```
and after a time delay (in milli seconds) since last keypress:
```toml
auto-save.after-delay.enable = true|false
auto-save.after-delay.timeout = [0, u64::MAX] # default: 3000
```
* Remove boilerplate and unnecessary types
* Remove more useless types
* Update docs for auto-save.after-delay
* Fix wording of (doc) comments relating to auto-save
* book: Move auto-save descriptions to separate section
---------
Co-authored-by: Miguel Perez <miguelvojito@gmail.com>
Co-authored-by: Miguel Perez <perezoji@cs.fsu.edu>
fsync(2) is a somewhat expensive operation that flushes writes to the
underlying disk/SSD. It's typically used by databases to ensure that
writes survive very hard failure scenarios like your cat kicking the
plug out of the wall. Synchronizing isn't automatically done by
`flush`ing (from the `std::io::Write` or `tokio::io::AsyncWriteExt`
traits). From the [`tokio::fs::File`] moduledocs:
> To ensure that a file is closed immediately when it is dropped, you
> should call `flush` before dropping it. Note that this does not ensure
> that the file has been fully written to disk; the operating system
> might keep the changes around in an in-memory buffer. See the
> `sync_all` method for telling the OS to write the data to disk.
[`tokio::fs::File`]: https://docs.rs/tokio/latest/tokio/fs/struct.File.html
Without a serializer, we drop the custom alphabet when making config
modifications like with `:set`. For example before this commit,
`:set mouse false` would reset a custom alphabet to the default.
This patch merges the last child of a container node to the parent. This
avoids the bug where uneven spaced Views would be created. To reproduce:
1. `vsplit`
2. `split`
3. `quit`
4. `vsplit`
With this patch the bug cannot be seen anymore.
In the `reload-all` command, we should not stop reloading the documents
if one error is found. Instead, we should report the error and continue
trying to reload the current open documents. This is useful in cases
where a backing file does not exist temporarily (e.g. when editing a git
patch in the outstanding chain that doesn't have a file just yet).
This change also remove the error messages in the cases where the
backing is `None`, like in new docs or `tutor`.
* feat: add 'file-abs-path' to statusline (#4434)
* cleanup implementation
* rename to be non-abbreviated names
---------
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
URIs need to be normalized to be comparable. For example a language
server could send a URI for a path containing '+' as '%2B' but we might
encode this in something like 'Document::url' as just '+'. We can
normalize the URI straight into a PathBuf though since this is the only
value we compare these diagnostics URIs against. This also covers
edge-cases like windows drive letter capitalization.