Commit graph

192 commits

Author SHA1 Message Date
Skyler Hawthorne
f486f34ebe
flush writes on force quit (#4397)
When force quitting, we need to block on the pending writes to ensure
that write commands succeed before exiting, and also to avoid a crash
when all the views are gone before the auto format call returns from
the LS.
2022-10-21 13:28:29 +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
Pascal Kuthe
9af7c1c9f3 Sort by fixed diagnostics/is_preffered within codeaction categories 2022-10-21 10:03:00 +09:00
Pascal Kuthe
189aa0bfcf never sort menu items when no fuzzy matching is possible 2022-10-21 10:03:00 +09:00
Pascal Kuthe
dc3527f52d use permalink to vscode repo 2022-10-21 10:03:00 +09:00
Pascal Kuthe
8d8b5d6624 use stable sort instead of allocating new vectors 2022-10-21 10:03:00 +09:00
Pascal Kuthe
8673c1ec0c sort codeaction by their kind instead of alphabetically 2022-10-21 10:03:00 +09:00
Blaž Hrastnik
78c0cdc519
Merge pull request #2267 from dead10ck/fix-write-fail
Write path fixes
2022-10-20 23:11:22 +09:00
Fisher Darling
4174b25b3d
Pretty print tree-sitter-subtree expression (#4295) 2022-10-19 17:17:50 -05:00
Skyler Hawthorne
756253b43f fix tree_sitter_scopes 2022-10-19 00:01:00 -04:00
Skyler Hawthorne
e645804b0a Editor::flush_writes returns an error 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
b530a86d1f remove Callback::Compositor variant
To reduce likelihood of accidental discarding of important callbacks
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
57de4e6251 various fixes in write-all path 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
e5fd5e2a9c fix panic when view of pending write is closed 2022-10-18 22:31:39 -04:00
Skyler Hawthorne
aaa1450678 fix write-quit with auto format
write-quit will now save all files successfully even when there is auto
formatting
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
b8a07f7d15 add conditional noop render back
It makes it much slower without stubbing this out
2022-10-18 22:31:38 -04:00
Skyler Hawthorne
69c9e44ef2 update write-quit to wait for saves 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
Roberto Vidal
1f74cf45d4
display tree sitter scopes in a popup (#4337) 2022-10-19 00:00:00 +05:30
ZJPzjp
0e8e7cae3b
fix :insert-output doc: inserting output **before** each selection (#4286) 2022-10-15 11:07:42 -05:00
Michael Davis
e16c632760
Apply transactions to the jumplist for undo/redo (#4227)
Undo/redo/earlier/later call `Document::apply_impl` which applies
transactions to the document. These transactions also need to be
applied to the view as in 0aedef0.
2022-10-13 00:57:40 +09:00
Michael Davis
c388e16e09 Add a helper function for applying transactions
It is easy to forget to call `Document::apply` and/or `View::apply` in
the correct order. This commit introduces a helper function which
closes over both calls.
2022-10-11 12:17:32 +09:00
Michael Davis
0aedef0333 Apply transactions to Views
This change adds View::apply calls for all Document::apply call-sites,
ensuring that changes to a document do not leave invalid entries in
the View's jumplist.
2022-10-11 12:17:32 +09:00
A-Walrus
1d8bb2249b
Change focus to modified docs on quit (#3872)
* Change focus to modified docs on quit

When quitting with modified documents, automatically switch focus to
one of them.

* Update helix-term/src/commands/typed.rs

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>

* Make it work with buffer-close-all and the like

* Cleanup

Use Cow instead of String, and rename DoesntExist -> DoesNotExist

Co-authored-by: Poliorcetics <poliorcetics@users.noreply.github.com>
2022-10-04 00:07:21 +09:00
ath3
7c9809eeb2
Find workspace from document path (#3553) 2022-10-04 00:02:49 +09:00
Joe
bcba5d67f9
Add goto preview (#2982) 2022-10-03 23:33:20 +09:00
Filipe Azevedo
385ccdfc9c
add :lsp-restart command (#3435) 2022-09-20 16:44:36 +09:00
Joe
aa00a470f3
Fix preview bug (#3644)
* Fix preview bug

* Add comment to empty case
2022-09-20 16:40:48 +09:00
A-Walrus
d38950bdf9
Remove border from code actions popup (#3444) 2022-09-13 05:24:48 -04:00
Blaž Hrastnik
c2e41082e4
Remove the .txt suffix from tutor
The tutor file is loaded as .txt which can potentially spawn a
language server. Then the path is unset, but the LS remains active.
This can cause panics since updates are now submitted for a doc
with no path.

As a quick workaround we remove the extension which should avoid
detection.

Fixes #3730
2022-09-11 11:11:07 +09:00
A-Walrus
75e6a64327 Switch to Result for invalid language 2022-09-10 22:23:38 +09:00
A-Walrus
e8add6f46d Add error handling to set language command
If you type a nonexistant language an appropriate message will show,
and the language won't be changed.
2022-09-10 22:23:38 +09:00
A-Walrus
e14b48af2e
Fix :reflow panic by enusring cursor in view (#3733) 2022-09-07 12:50:54 -05:00
Frojdholm
4c9f144dac
fix: Recalculate completion when going through prompt history (#3193)
* fix: Recalculate completion when going through prompt history

* Update completion when the prompt line is changed

It should not be possible to update the line without also updating the
completion since the completion holds an index into the line.

* Fix Prompt::with_line recalculate completion

with_line was the last function where recalculate completion had to be
done manually. This function now also recalculates the completion so
that it's impossible to forget.

* Exit selection when recalculating completion

Keeping the selection index when the completion has been recalculated
doesn't make sense. This clears the selection automatically, removing
most needs to manually clear it.

* Remove &mut on save_filter

Co-authored-by: Blaž Hrastnik <blaz@mxxn.io>
2022-09-01 01:26:21 +09:00
Michael Davis
5f043dde56
Derive Document language name from languages.toml name key (#3338)
* Derive Document language name from `languages.toml` `name` key

This changes switches from deriving the language name from the
`languages.toml` `scope` key to `name` (`language_id` in the
`LanguageConfiguration` type). For the most part it works to derive the
language name from scope by chopping off `source.` or `rsplit_once` on
`.` but for some languages we have now like html (`text.html.basic`),
it doesn't. This also should be a more accurate fallback for the
`language_id` method which is used in LSP and currently uses the
`rsplit_once` strategy.

Here we expose the language's name as `language_name` on `Document` and
replace ad-hoc calculations of the language name with the new method.

This is most impactful for the `file-type` statusline element which is
using `language_id`.

* Use `Document::language_name` for the `file-type` statusline element

The `file-type` indicator element in the statusline was using
`Document::language_id` which is meant to be used to for telling
Language Servers what language we're using. That works for languages
with `language-server` configurations in `languages.toml` but shows
text otherwise. The new `Document::language_name` method from the
parent commit is a more accurate way to determine the language.
2022-08-30 10:59:45 +09:00
Michael Davis
f32c05db85
Detect indent-style in :set-language (#3330)
Indent style may change when choosing a language with `:set-language`.
Line-endings most likely will not change, but `:set-language` should
have a similar effect as reloading a file (`:reload`), plus the two
are currently grouped in the implementation and line-ending detection
is not particularly expensive.
2022-08-05 09:11:31 +09:00
Matthias Deiml
0ee2061102
Avoid copying fragments (#3136)
* Avoid copying fragments

* Add slice / slices method

* Better documentation for fragment and slice methods
2022-08-04 14:44:43 +09:00
Danilo Spinella
110eb73045
Add cwd parameter which is not optional anymore (#3240) 2022-07-31 06:59:15 -05:00
Gokul Soumya
a8b123fe17
Fix byte index error in signature help highlighting
The language server sends a char offset range within the
signature help label text to highlight as the current parameter,
but helix uses byte offset ranges for rendering highlights. This
was brought up in the [review of the original signature help PR][1],
but the ranges were being highlighted correctly, and there were no
out of bound or indexing panics. Turns out rust-analyzer was
[incorrectly sending byte offsets] instead of char offsets and this
made it seem like all was well and good with offsets in helix during
initial testing.

[1]: https://github.com/helix-editor/helix/pull/1755#discussion_r906715371
[2]: https://github.com/rust-lang/rust-analyzer/pull/12272
2022-07-29 14:31:21 +09:00
Gokul Soumya
de8ade8967
Shorten embedded command descriptions (#3070)
* Shorten embedded command descriptions

- Compact descriptions in command palette and infobox

* Shorten typed command descriptions

* Fix typo in decrement command description
2022-07-26 12:04:23 +09:00
Alexis Kalabura
8b2a14153b
add statusline element to display file line endings (#3113)
* add statusline element to display file line endings

* run cargo fmt --all

* change the word *ending* from plural to singular

* support for the unicode-lines feature flag
2022-07-21 13:03:12 +09:00