Commit Graph

7768 Commits

Author SHA1 Message Date
Kirill Bulatov
1c4be24fb7 Move gpui derives tests into gpui crate to avoid dependency cycles
`cargo run` on Zed project leads to rust-analyzer evantually emitting

`[ERROR project_model::workspace] cyclic deps:
gpui_macros(Idx::<CrateData>(269)) -> gpui(Idx::<CrateData>(264)),
alternative path: gpui(Idx::<CrateData>(264)) ->
gpui_macros(Idx::<CrateData>(269))`

error after loading the project.

The PR fixes this by moving away the test to the "root" project.
2023-08-16 10:19:20 +03:00
Mikayla Maki
facb942156
Add component traits to GPUI (#2850)
Release Notes:

- N/A
2023-08-15 15:53:12 -07:00
Mikayla
7d3ffae47d
move component into gpui 2023-08-15 15:44:59 -07:00
Max Brunsfeld
3623a9ca5e Simplify Component implementation
Co-authored-by: Mikayla <mikayla@zed.dev>
2023-08-15 15:26:02 -07:00
Kirill Bulatov
2670e2c9ec
Support editor::SelectAll in Terminal (#2848)
![image](https://github.com/zed-industries/zed/assets/2690773/3aae1e6a-9993-4e65-8ed1-20f2f4b452df)

Allows to use `editor::SelectAll`(`cmd-a` by default) in Terminal to
select all text in it, for future copying.
Currently, does not try to be smart and trim the selected whitespaces
after the last prompt, and copies them too.

Release Notes:

- Support `editor::SelectAll` in Terminal
2023-08-15 23:59:26 +03:00
Kirill Bulatov
de69f08c10 Support editor::SelectAll in Terminal 2023-08-15 23:43:32 +03:00
Joseph T. Lyons
d6ca0a1f24 Associate extensions with language 2023-08-15 16:33:02 -04:00
Conrad Irwin
404b1aa65a
Fix vim selection to include entire range (#2787)
Update vim mode to have vim selection and editor selections match.
Before this we had to adjust between vim selections and real selections
when making changes; now we have to adjust when making selections.

Release Notes:

- vim: Ensure editor selection matches the vim selection
([#1796](https://github.com/zed-industries/community/issues/1796)).
- vim: Fix `s` in visual line mode
- vim: Add `o` and `shift-o` to toggle direction of visual selection
- vim: Fix `v` and `shift-v` to toggle back to normal mode
- vim: Fix block selections like `vi}` to contain correct whitespace
2023-08-15 08:36:17 -06:00
Conrad Irwin
1e3f468fc7
Fix vim escape in normal mode (#2844)
Fixes: zed-industries/community#1857

- vim: Fix escape in normal mode
([#1857](https://github.com/zed-industries/community/issues/1857)).
2023-08-15 08:35:49 -06:00
Mikayla Maki
22da42fc69
Add components example (#2846)
This PR is a continuation of the components UI exploration I've been
doing. It adds an example to the GPUI examples page and totally
restructures the generics on our MouseEventHandler.

Release Note:
- N/A
2023-08-15 03:17:50 -07:00
Mikayla
e5eed29c72
Add components example
Re-arrange generics on mouse event handler
Add TypeTag struct for dynamically tagged components
2023-08-15 03:06:43 -07:00
Conrad Irwin
1af7425059 Fix vim escape in normal mode
Fixes: zed-industries/community#1857
2023-08-14 16:05:41 -06:00
Conrad Irwin
fb90eada70 Merge branch 'main' into vim-visual-selection 2023-08-14 15:29:33 -06:00
Conrad Irwin
5b37cdcb04 Better tests 2023-08-14 15:03:16 -06:00
Kirill Bulatov
64c2043913
Query less inlay hints (#2842)
Part of
https://linear.app/zed-industries/issue/Z-2750/investigate-performance-of-collaborating-on-large-files-with-inlay

Instead of querying the entire file for hints, query visible editor(s)
range + the areas above and below, of the same height.
Non-invalidating future queries (e.g. scrolling) query only missing
parts of the ranges.

Release Notes:

- Improved LSP resource usage by querying less hints for big files
2023-08-14 23:06:30 +03:00
Kirill Bulatov
27bf01c3a8 Strip off inlay hints data that should be resolved 2023-08-14 22:50:55 +03:00
Kirill Bulatov
e0d011e354 Better assert multibuffer edit test results 2023-08-14 20:12:35 +03:00
Kirill Bulatov
4b3273182a Do not filter out hints to be removed 2023-08-14 19:20:20 +03:00
Kirill Bulatov
336fbb3392 Clip offsets in inlay hint queries 2023-08-14 18:39:30 +03:00
Kirill Bulatov
558367dc8b Optimize query ranges tracking 2023-08-14 16:19:44 +03:00
Kirill Bulatov
87e6651ecb Fix hint tests, add a char boundary bug test 2023-08-14 16:01:02 +03:00
Kirill Bulatov
449c009639 Properly generate ranges to query 2023-08-14 11:25:02 +03:00
Kirill Bulatov
56f89739f8 Do not add duplicate hints to the cache 2023-08-14 11:25:02 +03:00
Kirill Bulatov
0e2a1fc149 Query inlay hints for parts of the file 2023-08-14 11:25:02 +03:00
Kirill Bulatov
708409e06d Query hints on every scroll 2023-08-14 11:25:02 +03:00
Kirill Bulatov
5d2750e0d4 Hide inlay cache fields 2023-08-14 11:25:02 +03:00
Mikayla
29a85635ea
Make each setting optional 2023-08-12 12:23:46 -07:00
Mikayla
563b25f26f
Add deserialization helper 2023-08-12 12:21:44 -07:00
Nathan Sobo
fa7ebd0825 Include drop shadows with different corner radii in the example 2023-08-12 11:08:58 -06:00
Nathan Sobo
65123e6eed Allow individual corner radii on drop shadows 2023-08-12 10:58:08 -06:00
Nathan Sobo
40f478937e Allow distinct corner radii for images 2023-08-12 10:50:04 -06:00
Nathan Sobo
84dc4090bd Wire up per corner radii for quad
Still need to expose this in the styling layer and allow images
to have per corner radii.
2023-08-12 10:40:23 -06:00
Mikayla
7970406694
Add a compile test for the element derive 2023-08-11 18:00:12 -07:00
Piotr Osiewicz
ffffbbea1f
chore: use Cow instead of String for tooltips (#2838)
A QoL change to align `Tooltip` with other elements like `Label`
Release Notes:

- N/A
2023-08-11 15:29:55 +02:00
Kirill Bulatov
704ab33f72 Restore shutdown behavior 2023-08-09 23:39:21 +03:00
Joseph T. Lyons
230b894871 v0.100.x dev 2023-08-09 12:30:39 -04:00
Mikayla Maki
40030f32d9
Fix two mouse event bugs (#2835)
This PR fixes two bugs we discovered in Zed's mouse event handling while
investigating an interesting and mysterious bug we we were seeing, where
spurious `MouseMoved` events would continuously be dispatched after
control-clicking.

Release Notes:

- Fixed a rendering glitch that could occur after control-clicking
certain elements.
2023-08-09 09:04:32 -07:00
Nate Butler
af388e7f9c Only load TTF fonts for now, additional font types will need to be manually added
Co-Authored-By: Julia <30666851+ForLoveOfCats@users.noreply.github.com>
2023-08-09 11:38:02 -04:00
Nate Butler
b23f1c809a WIP add IBM Plex Sans
(base) natebutler@Nate16 zed % cargo run
   Compiling zed v0.99.0 (/Users/natebutler/Code/zed/zed/crates/zed)
    Finished dev [unoptimized + debuginfo] target(s) in 9.15s
     Running `target/debug/Zed`
Thread "main" panicked with "called `Result::unwrap()` on an `Err` value: parse error" at crates/zed/src/main.rs:667:10
   0: backtrace::backtrace::libunwind::trace
             at /Users/natebutler/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/backtrace/libunwind.rs:93:5
      backtrace::backtrace::trace_unsynchronized
             at /Users/natebutler/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/backtrace/mod.rs:66:5
   1: backtrace::backtrace::trace
             at /Users/natebutler/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/backtrace/mod.rs:53:14
   2: backtrace::capture::Backtrace::create
             at /Users/natebutler/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/capture.rs:176:9
   3: backtrace::capture::Backtrace::new
             at /Users/natebutler/.cargo/registry/src/index.crates.io-6f17d22bba15001f/backtrace-0.3.68/src/capture.rs:140:22
   4: Zed::init_panic_hook::{{closure}}
             at crates/zed/src/main.rs:436:29
   5: std::panicking::rust_panic_with_hook
   6: std::panicking::begin_panic_handler::{{closure}}
   7: std::sys_common::backtrace::__rust_end_short_backtrace
   8: _rust_begin_unwind
   9: core::panicking::panic_fmt
  10: core::result::unwrap_failed
  11: core::result::Result<T,E>::unwrap
             at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/core/src/result.rs:1089:23
  12: Zed::load_embedded_fonts
             at crates/zed/src/main.rs:664:5
  13: Zed::main
             at crates/zed/src/main.rs:80:5
  14: core::ops::function::FnOnce::call_once
             at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/core/src/ops/function.rs:250:5
  15: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/std/src/sys_common/backtrace.rs:134:18
  16: std::rt::lang_start::{{closure}}
             at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/std/src/rt.rs:166:18
  17: std::panicking::try
  18: std::rt::lang_start_internal
  19: std::rt::lang_start
             at /private/tmp/rust-20230613-7622-103lepv/rustc-1.70.0-src/library/std/src/rt.rs:165:17
  20: _mai
2023-08-09 11:01:20 -04:00
Nathan Sobo
8ed5e8f86d
Pass PaintContext to Element::paint (#2788)
I want to use this on another branch, but it's a sweeping change, so
this prepares the ground for it. This can always be reverted if it
doesn't work out.
2023-08-08 21:16:57 -06:00
Joseph T. Lyons
bed0d1d529
Fix language detection when file name begins with a . (#2833)
I went to add in `zprofile` to the bash language config to get syntax
highlighting for it. After adding it in, Zed was still not highlighting
the file. I checked and saw that we are using `Path::extension()` in
`language_for_file()`, which [returns `None` when a file's name begins
with a
`.`](https://doc.rust-lang.org/std/path/struct.PathBuf.html#method.extension),
such as in the case of `.zprofile`. This PR adds a custom method, with
some tests, that just tries to grab the last component in the file name
if `Path::extension` returns `None`. Not sure if `ext` is the best name,
but I can't use `extension`.

Maybe this method should be called `extension_or_hidden_file_name()`?

Release Notes:

- Fixed a bug where language detection would fail for files starting
with `.` in their names.
- Added syntax highlighting for `.zprofile` files
2023-08-08 21:48:56 -04:00
Joseph T. Lyons
c523ccc4c7 Fix code that identifies language via extension 2023-08-08 21:35:11 -04:00
Max Brunsfeld
0b93a30821 Terminate synthetic drag state on mouse up w/ ctrl held
Co-authored-by: Mikayla <mikayla@zed.dev>
2023-08-08 17:39:45 -07:00
Max Brunsfeld
e3bb5e5103 Fix failure to remove hovered region_ids on element removal
Co-authored-by: Mikayla <mikayla@zed.dev>
2023-08-08 17:39:05 -07:00
Nathan Sobo
db96fb1307 Merge remote-tracking branch 'origin/main' into paint-context 2023-08-08 18:27:16 -06:00
Nathan Sobo
54ca5f1d44
Replace context methods that take a window id with methods on window handles (#2832)
With this PR, I've eliminated almost all references to window ids
outside of the internals of GPUI. All public methods taking these ids
are now defined on `AnyWindowHandle`, which provides a more coherent
narrative around windows as a concept.
2023-08-08 17:51:37 -06:00
Nathan Sobo
0dc70e6cbf Rename mac platform Window to MacWindow for clarity 2023-08-08 17:21:06 -06:00
Nathan Sobo
fc96676662 Use AppContext::update when updating windows so we handle effects 2023-08-08 17:20:46 -06:00
Nathan Sobo
8e49d1419a Minimize window id usage 2023-08-08 16:38:46 -06:00
Nathan Sobo
afd89b256a Store AnyWindowHandles instead of usizes 2023-08-08 16:06:53 -06:00