input: Update GPUI and fix Input changes. (#437)

Ref https://github.com/zed-industries/zed/pull/20968
This commit is contained in:
Jason Lee 2024-11-26 21:41:34 +08:00 committed by GitHub
parent 931d762955
commit 0119c80120
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 16 deletions

26
Cargo.lock generated
View file

@ -474,7 +474,7 @@ dependencies = [
"bitflags 2.6.0",
"cexpr",
"clang-sys",
"itertools 0.13.0",
"itertools 0.11.0",
"log",
"prettyplease",
"proc-macro2",
@ -950,7 +950,7 @@ dependencies = [
[[package]]
name = "collections"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"rustc-hash",
]
@ -1313,7 +1313,7 @@ dependencies = [
[[package]]
name = "derive_refineable"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"proc-macro2",
"quote",
@ -2266,7 +2266,7 @@ dependencies = [
[[package]]
name = "gpui"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"anyhow",
"as-raw-xcb-connection",
@ -2365,7 +2365,7 @@ dependencies = [
[[package]]
name = "gpui_macros"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"proc-macro2",
"quote",
@ -2555,7 +2555,7 @@ dependencies = [
[[package]]
name = "http_client"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"anyhow",
"bytes",
@ -3071,12 +3071,11 @@ dependencies = [
[[package]]
name = "media"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"anyhow",
"bindgen",
"core-foundation 0.9.4",
"ctor",
"foreign-types",
"metal",
"objc",
@ -3380,7 +3379,7 @@ version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "af1844ef2428cc3e1cb900be36181049ef3d3193c63e43026cfe202983b27a56"
dependencies = [
"proc-macro-crate 3.2.0",
"proc-macro-crate 1.3.1",
"proc-macro2",
"quote",
"syn 2.0.86",
@ -4351,7 +4350,7 @@ dependencies = [
[[package]]
name = "refineable"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"derive_refineable",
]
@ -4672,7 +4671,7 @@ checksum = "d369a96f978623eb3dc28807c4852d6cc617fed53da5d3c400feff1ef34a714a"
[[package]]
name = "semantic_version"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"anyhow",
"serde",
@ -5090,7 +5089,7 @@ checksum = "13c2bddecc57b384dee18652358fb23172facb8a2c51ccc10d74c157bdea3292"
[[package]]
name = "sum_tree"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"arrayvec",
"log",
@ -5749,7 +5748,7 @@ checksum = "09cc8ee72d2a9becf2f2febe0205bbed8fc6615b7cb429ad062dc7b7ddd036a9"
[[package]]
name = "util"
version = "0.1.0"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#0e42c019fe7ecb989586e50e7a94f06017395134"
source = "git+https://github.com/huacnlee/zed.git?branch=export-platform-window#54853c7ea3142578a9666c6723c09e92670aec71"
dependencies = [
"anyhow",
"async-fs 1.6.0",
@ -5763,6 +5762,7 @@ dependencies = [
"rust-embed",
"serde",
"serde_json",
"smol",
"take-until",
"tendril",
"unicase",

View file

@ -463,7 +463,7 @@ impl TextInput {
}
let old_text = self
.text_for_range(self.range_to_utf16(&range), cx)
.text_for_range(self.range_to_utf16(&range), &mut None, cx)
.unwrap_or("".to_string());
let new_range = range.start..range.start + new_text.len();
@ -552,9 +552,11 @@ impl TextInput {
let mut start = self.offset_to_utf16(offset);
let mut end = start;
let prev_text = self.text_for_range(0..start, cx).unwrap_or_default();
let prev_text = self
.text_for_range(0..start, &mut None, cx)
.unwrap_or_default();
let next_text = self
.text_for_range(end..self.text.len(), cx)
.text_for_range(end..self.text.len(), &mut None, cx)
.unwrap_or_default();
let prev_chars = prev_text.chars().rev().peekable();
@ -739,9 +741,11 @@ impl ViewInputHandler for TextInput {
fn text_for_range(
&mut self,
range_utf16: Range<usize>,
adjusted_range: &mut Option<Range<usize>>,
_cx: &mut ViewContext<Self>,
) -> Option<String> {
let range = self.range_from_utf16(&range_utf16);
adjusted_range.replace(self.range_to_utf16(&range));
Some(self.text[range].to_string())
}