Commit Graph

7718 Commits

Author SHA1 Message Date
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
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
Piotr Osiewicz
c96b03ae55
Piotr/optimize search selections with a limit (#2831)
/cc @nathansobo @maxbrunsfeld 

Release Notes:
- Fixed scrollbar selections causing noticeable slowdowns with large
quantities of selections.
2023-08-08 21:29:24 +02:00
Nathan Sobo
b77c336a3d Return window handles from WeakItemHandle 2023-08-08 11:39:56 -06:00
Nathan Sobo
b2d9ccc0a2 Move more window methods off AsyncAppContext 2023-08-08 11:38:07 -06:00
Nathan Sobo
95cd96e4be Move debug_elements to AnyWindowHandle 2023-08-08 11:27:19 -06:00
Nathan Sobo
4f10f0ee86 Remove window methods from AsyncAppContext 2023-08-08 11:23:49 -06:00
Nathan Sobo
1fd80ba8bd Remove AsyncAppContext::remove_window 2023-08-08 11:22:43 -06:00
Nathan Sobo
fe6a1886c1 Remove unused dock code 2023-08-08 11:20:42 -06:00
Nathan Sobo
0a4633f88f Remove more window id usage 2023-08-08 11:20:09 -06:00
Nathan Sobo
da7dc9c880 Work with window handles instead of ids in drag code 2023-08-08 11:14:02 -06:00
Nathan Sobo
d896d89842 Store an AnyWindowHandle in WindowContext 2023-08-08 11:08:37 -06:00
Nathan Sobo
49f1f1c6c2 Remove window when closing workspace in test 2023-08-08 09:13:17 -06:00
Piotr Osiewicz
1aff642981 Do not highlgiht selections at all over the threshold 2023-08-08 13:09:27 +02:00
Nathan Sobo
dba2facd23 Remove window via handles 2023-08-07 22:58:01 -06:00
Nathan Sobo
f0da6b05fd Remove TestAppContext::add_view
Instead, we now call this on window handles.
2023-08-07 22:46:48 -06:00
Nathan Sobo
0f332238b3 Remove unused method 2023-08-07 22:08:44 -06:00
Nathan Sobo
d687c3d81f Merge remote-tracking branch 'origin/main' into window-handles 2023-08-07 22:07:20 -06:00
Nathan Sobo
f2be3181a9 Move window-related methods from TestAppContext to AnyWindowHandle 2023-08-07 20:23:04 -06:00
Nathan Sobo
0197d49230 Move activation simulation to AnyWindowHandle 2023-08-07 19:45:43 -06:00
Nathan Sobo
486f5bc6ca Get compiling 2023-08-07 19:08:58 -06:00
Piotr Osiewicz
371c669e00 Address review feedback.
Rename selected_rows to background_highlight_row_ranges.
Do not return any ranges if there are more than 50k results
2023-08-08 02:47:49 +02:00
Piotr Osiewicz
b0fc6da55b Use display maps 2023-08-08 02:37:27 +02:00
Piotr Osiewicz
241d3951b8 Remove redundant argument 2023-08-08 02:25:30 +02:00
Piotr Osiewicz
42e1221357 Add upper bound limit. Remove dbg! statements 2023-08-08 02:17:11 +02:00
Piotr Osiewicz
fa16895976 Do not query start of range if it's end is the same as the previous hunk's 2023-08-08 00:27:38 +02:00
Piotr Osiewicz
ca21626064 Baseline: Improve selection rendering for large quantities from 270ms to 90ms 2023-08-07 23:32:27 +02:00
Max Brunsfeld
7288be4251
Make LspAdapter::process_diagnostics synchronous (#2829)
When editing rust code, the project diagnostics view sometimes fails to
update, so that you have to close the view and re-open it to see the
correct state.

This PR fixes one possible cause of that problem. There was an async
step in between *receiving* diagnostics from the language server and
updating the diagnostics, due to an async call to
`LspAdapter::process_diagnostics`. This could cause the following
sequence of events to happen:

1. Rust-analyzer sends us new diagnostics for a file `a.rs`
2. We call `process_diagnostics` with those diagnostics
3. Rust-analyzer sends us a `WorkDoneProgress` message, indicating that
the "flycheck" (aka `cargo check`) process has completed
4. We update the project diagnostics view due to this message.
5. The `process_diagnostics` call for `a.rs` completes
6. 💥 We have the new diagnostics for `a.rs`, but do not update the
project diagnostics view again.

This PR fixes this bug by simply making `process_diagnostics`
synchronous. There is no I/O or expensive computation happening in that
method. If we need to make it asynchronous in the future, we need to
introduce a queue that ensures that `publishDiagnostics` and
`workDoneProgress` messages are processed serially.

Release Notes:

- Fixed a bug where the project diagnostics view would sometimes fail to
update properly when using Rust-analyzer.
2023-08-07 14:31:49 -07:00
Joseph T. Lyons
dbf25ea2ff Add syntax highlighting for Cargo.toml files 2023-08-07 17:24:22 -04:00
Joseph T. Lyons
580c2ea8eb Fix test name 2023-08-07 17:07:01 -04:00
Max Brunsfeld
4e33654aba Make LspAdapter::process_diagnostics synchronous
Co-authored-by: Nathan <nathan@zed.dev>
2023-08-07 13:53:41 -07:00
Nathan Sobo
3e0d0e5c01 WIP 2023-08-07 13:54:47 -06:00
Nathan Sobo
d4d32611fe WIP 2023-08-06 18:57:02 -06:00
Nathan Sobo
adc50469ff WIP 2023-08-06 12:45:31 -06:00
Joseph T. Lyons
ef5b982ea5 Fix bash path_suffixes and add line_comment 2023-08-06 02:20:31 -04:00
Nathan Sobo
dcf8b00656 WIP 2023-08-05 18:00:44 -06:00
Joseph T. Lyons
1abb6a0176 Expand empty selections to cover full word and fix bugs 2023-08-05 11:31:21 -04:00
Joseph T. Lyons
12e8f417e4 Add more convert to case commands
ConvertToTitleCase
ConvertToSnakeCase
ConvertToKebabCase
ConvertToUpperCamelCase
ConvertToLowerCamelCase
2023-08-04 22:45:26 -04:00
Joseph T. Lyons
8c98b02e45 Add convert to {upper,lower} case commands
Co-Authored-By: Julia <30666851+ForLoveOfCats@users.noreply.github.com>
2023-08-04 15:10:33 -04:00
Nathan Sobo
d3c1966d96
WIP: Return WindowHandle<V: View> from AppContext::add_window (#2820)
Instead of returning a usize for the window id, I'm instead returning a
`WindowHandle<V: View>` where `V` is the type of the window's root view.
@as-cii helped me with a cool technique using generic associated types
where methods on `WindowHandle` can return either T or Option<T>
depending on the `BorrowWindowContext::Result` associated type.

Some example usage...

```rs
let window = cx.add_window(|cx| MyView::new(cx));
let my_view = window.root(cx); // If cx is TestAppContext, returns MyView. Otherwise returns Option<MyView>, because the window could be closed.
```


This isn't insanely beneficial on its own, but I think it will help
clean up our testing story. I'm planning on making `window` more useful
in tests for laying out elements, etc.

- [x] Rework tests that call `add_window` 😅 to expect only a window in
return.
- [x] Get tests passing
- [x] 🚬  test
2023-08-03 18:45:51 -06:00
Nathan Sobo
2d96388be3 Use WindowHandles in a couple places 2023-08-03 17:46:34 -06:00