Commit Graph
215 Commits
Author SHA1 Message Date
Julia 1e78c24e45 Merge pull request #1451 from zed-industries/tab-auto-indent
Auto-indent on tab for cursors left of the suggested indent level
2022-08-02 15:52:12 -04:00
Antonio Scandurra 84b1a2722e Compute diffs based on characters rather than lines
Previously, a change on a given line would cause that whole line to be
replaced. In turn, this caused anchors on that line to go to the start
of that line because they would lie inside of a deleted region after applying
the diff.

By switching to a character-wise diff, we perform smaller edits to the buffer
which stabilizes anchor positions.
2022-08-02 16:52:37 +02:00
Max BrunsfeldandJulia Risley 8505231e9a Start work on auto-indenting lines on tab
Co-authored-by: Julia Risley <floc@unpromptedtirade.com>
2022-08-01 16:47:59 -07:00
Max Brunsfeld 2c732526a9 Fix mistakes in editor auto-indent test 2022-08-01 11:02:29 -07:00
Max Brunsfeld 75c349243c 🎨 Rename and simplify some autoindent stuff 2022-07-28 22:40:30 -07:00
Max Brunsfeld 357c9d53a9 Record start columns when writing to the clipboard from Zed 2022-07-28 22:13:32 -07:00
Max Brunsfeld 345e33fa98 Start work on adjusting pasted text based on old start column 2022-07-28 17:29:42 -07:00
Max BrunsfeldandMikayla Maki 669d716519 Introduce AutoindentMode parameter to Buffer::edit
This controls whether or not we preserve the relative indentation
of inserted text blocks.

Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2022-07-28 14:03:31 -07:00
Max BrunsfeldandMikayla Maki 48610f5819 Remove indent_size parameter from Buffer::edit_with_autoindent
Instead, compute the indent size by reading the settings inside that method.

Co-authored-by: Mikayla Maki <mikayla.c.maki@gmail.com>
2022-07-28 13:00:05 -07:00
Max Brunsfeld d349ca1f4e Fix error in autoindent range calculation 2022-07-28 11:51:03 -07:00
Max Brunsfeld 1a1b7810b7 Restructure autoindent to preserve relative indentation of inserted text 2022-07-26 17:43:43 -07:00
Max Brunsfeld 0232aba028 🎨 compute_autoindents 2022-07-26 17:09:30 -07:00
Max Brunsfeld 07f1486c13 Improve calculation of which lines are new when auto-indenting 2022-07-26 17:09:30 -07:00
Antonio Scandurra 47fce17ff8 Merge branch 'main' into ime-support-2 2022-07-25 10:47:49 +02:00
Antonio Scandurra daff3fc7f6 Coalesce IME compositions into a single edit 2022-07-25 09:53:51 +02:00
K Simmons f14c30511d add test coverage for diagnostic popover 2022-07-20 19:02:33 -07:00
Antonio Scandurra 9de9d517fd Differentiate among tabs with the same name
This commit introduces a new, optional `Item::tab_description` method
that lets implementers define a description for the tab with a certain
`detail`. When two or more tabs match the same description, we will
increase the `detail` until tabs don't match anymore or increasing the
`detail` doesn't disambiguate tabs any further.

As soon as we find a valid `detail` that disambiguates tabs enough, we
will pass it to `Item::tab_content`. In `Editor`, this is implemented by
showing more and more of the path's suffix as `detail` is increased.
2022-07-14 11:54:11 +02:00
Max Brunsfeld 559f6854d0 Upgrade Tree-sitter and limit query cursors' concurrently-buffered matches 2022-07-08 14:09:34 -07:00
Antonio Scandurra 3b345cba67 Allow providing an external format in format_on_save setting 2022-07-07 11:04:03 +02:00
Antonio ScandurraandMax Brunsfeld 6d573a2822 Normalize line endings when parsing completions
Co-Authored-By: Max Brunsfeld <max@zed.dev>
2022-07-06 19:32:45 +02:00
Antonio Scandurra f94bfeb1cc Fix panic on paste when editing with auto-indent
Instead of accepting text as it's input by the user, we will read it
out of the edit operation after it gets sanitized by the buffer.
2022-07-06 19:00:11 +02:00
Max BrunsfeldandKeith Simmons e6c9549bbd Strip carriage returns from all text in text::Buffer
* Moving the logic from Rope to text::Buffer makes it easier
  to keep the Rope in sync with the fragment tree.
* Removing carriage return characters is lossier, but is much
  simpler than incrementally maintaining the invariant that
  there are no carriage returns followed by newlines. We may
  want to do something smarter in the future.

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-07-05 17:25:09 -07:00
Max Brunsfeld 69ed736484 Change Buffer constructors to construct the History internally 2022-07-05 14:51:52 -07:00
Antonio Scandurra a90a086c3e Transmit new line ending when buffer is reloaded 2022-07-05 08:01:14 +02:00
Max Brunsfeld bf20993000 Rename NewlineStyle -> LineEnding 2022-07-04 12:47:40 -07:00
Max Brunsfeld 31ca4c5efa Handle a file's line endings changing on disk 2022-07-04 12:30:28 -07:00
Antonio Scandurra 472b53db01 Ignore carriage returns when reloading buffer 2022-07-04 17:40:35 +02:00
Antonio Scandurra f356219cd2 Detect buffer newline style and honor it when saving 2022-07-04 17:40:26 +02:00
Max Brunsfeld d9de9f4afa In most languages, use prev non-empty line as basis for preserving indent 2022-06-28 12:21:54 -07:00
Max Brunsfeld 7610a6a72d Add new indentation features to support Python 2022-06-27 22:34:14 -07:00
Max Brunsfeld 3527013928 Add python outline and bracket queries 2022-06-22 16:28:09 -07:00
Antonio Scandurra 18631fd3d0 Merge pull request #1204 from zed-industries/accurate-is-dirty
Determine `Buffer::is_dirty` based on the rope's fingerprint
2022-06-17 16:08:07 +02:00
Antonio Scandurra 42064f76b0 Don't compute fingerprint for every text summary 2022-06-17 15:15:27 +02:00
Antonio Scandurra 5ad9e9e6c8 Determine Buffer::is_dirty based on the rope's fingerprint 2022-06-17 12:38:25 +02:00
Max Brunsfeld 54abc9864a Disable auto-indent entirely for markdown 2022-06-16 14:20:09 -07:00
Antonio Scandurra 306b76e782 Use word boundaries instead of syntax to infer completion edit ranges 2022-06-16 11:27:22 +02:00
Max Brunsfeld 2e11995a75 Merge pull request #1155 from zed-industries/golang
Add Go support
2022-06-09 14:18:37 -07:00
Max Brunsfeld 01aca3b128 Add tests and fix bugs for editor indent/outdent commands w/ hard tabs 2022-06-09 10:26:09 -07:00
Max Brunsfeld 60335c5d1c Add support for hard tabs
* Add a `hard_tabs` setting that causes indentation to be performed
  using a tab instead of multiple spaces.
* Change Buffer's indentation-related APIs to return an `IndentSize`
  struct with a length and a kind, instead of just a single u32.
* Use hard tabs by default in Go.
2022-06-08 18:30:10 -07:00
Antonio Scandurra 96602c79bc Render a "Jump to Buffer" icon on all excerpt headers 2022-06-08 15:31:29 +02:00
Antonio Scandurra 19047bd204 Snapshot file instead of path when creating a buffer snapshot 2022-06-08 14:29:14 +02:00
Antonio Scandurra dc056176f2 Make Buffer::edit and MultiBuffer::edit resilient to inverted ranges
Previously, we would accept edits containing out-of-order ranges. When
generating such ranges in our randomized tests, many invariants started
breaking causing e.g. undo/redo to misbehave and operation application
to panic.

In theory, we should never pass inverted ranges, but this commit changes
the above functions to swap the start and the end when that occurs to avoid
breaking the entire system and panicking.
2022-06-06 15:22:36 +02:00
Keith Simmons be8bfa9592 WIP line mode operations 2022-05-26 17:02:05 -07:00
Keith Simmons 94b6f4beb5 Merge pull request #929 from zed-industries/non-uniform-batched-edits
Allow batched edits where each range is associated with different insertion text
2022-04-29 16:14:38 -07:00
Keith Simmons 47d4f42467 Consolidate edit and edit_batched functions 2022-04-28 16:52:04 -07:00
Keith Simmons 5f9259719d Removed unnecessary debug statements 2022-04-28 09:20:56 -07:00
Keith Simmons 5051769dd3 Building, but failing test WIP 2022-04-27 17:25:38 -07:00
Max Brunsfeld a43d10518d Infer completions old ranges based on the syntax tree 2022-04-25 13:14:05 -07:00
Max Brunsfeld 6b73d44d65 Fix missing TypeScript outline entries and breadcrumbs 2022-04-22 13:49:03 -07:00
Max BrunsfeldandKeith Simmons e7039c123d Avoid maintaining indent size as state on buffers
Indent size is still hard-coded, but it's now controlled by the
editor and not the buffer.

Co-authored-by: Keith Simmons <keith@zed.dev>
2022-04-06 10:22:29 -07:00