Порівняти коміти

..
Автор SHA1 Повідомлення Дата
l0ng-ai 989a552583 fix(app): open middle-clicked links in the browser 2026-11-21 19:33:02 +08:00
19 змінених файлів з 156 додано та 425 видалено

No files matched your search

Створено
+76 -67
Переглянути файл
@@ -1203,27 +1203,27 @@ dependencies = [
[[package]]
name = "cranelift-assembler-x64"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c19fba13ee427c4dd29488ea51127e945bf07fd9d79093f14c9cc57f74acf757"
checksum = "aecefa88696b62f833cc0c997d19c93246b0268e2aaf23e0e8692e527f6de088"
dependencies = [
"cranelift-assembler-x64-meta",
]
[[package]]
name = "cranelift-assembler-x64-meta"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "dd88c766346fcc14bbadbd68cb11e9bc1e555e99f7e8f6b1f4c27a73ca659bec"
checksum = "1391a2546f5edf06a0ff5e9430d73c2713fd536aefec53200dc21846d1467f53"
dependencies = [
"cranelift-srcgen",
]
[[package]]
name = "cranelift-bforest"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f19d43d75dd963d6b1a653f2e03d4eed4365ca2e598ec57e52c15afdad6c3276"
checksum = "9528915fbc2c950702329e08c6d72aaff8ece9b7ecdbd225742825c09a445227"
dependencies = [
"cranelift-entity",
"wasmtime-internal-core",
@@ -1231,9 +1231,9 @@ dependencies = [
[[package]]
name = "cranelift-bitset"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "45d0b93e50856858c89c61cbe3f6d4b07596da22eb5a03a95b19420e1d08a275"
checksum = "9dd69a6db85c1bcff989809e0e0b3b06506425f32b545c46aeafda5fe7775d6a"
dependencies = [
"serde",
"serde_derive",
@@ -1242,9 +1242,9 @@ dependencies = [
[[package]]
name = "cranelift-codegen"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "efbdff32d3b6b4f33f1ba8a4ac747b97ce569b1d6834c3089c1c0933b94e618c"
checksum = "24c2db6c26cd96393cf785c4b51b900738963cc7422aa0045416a7641ae2f6cd"
dependencies = [
"bumpalo",
"cranelift-assembler-x64",
@@ -1273,9 +1273,9 @@ dependencies = [
[[package]]
name = "cranelift-codegen-meta"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "67fd11ff24916a2c1ff852ce4bb664fcf2c2970ed551de44dd5b573321123703"
checksum = "e284270142e7f1dcb73a992a62a8b3716b4062a65a52d8f2732c6ebf6f7f342f"
dependencies = [
"cranelift-assembler-x64-meta",
"cranelift-codegen-shared",
@@ -1286,24 +1286,24 @@ dependencies = [
[[package]]
name = "cranelift-codegen-shared"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba5d321229c3e00a17d7bb3633529ffdf97a13bcf4962fd2e92f1e0fd39360aa"
checksum = "6595667b7d505cf85d5bdd014e6f57ad6128183238f8e372319d9384782472f5"
[[package]]
name = "cranelift-control"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "71cd63450256d0f80f7a0527e133452f84fa6e1ca73c7db6ca2a9e8cc89d1c18"
checksum = "f26ffdbfcd24c3833d730849e6d132af34a400a2b89b44446015c01eecbea21d"
dependencies = [
"arbitrary",
]
[[package]]
name = "cranelift-entity"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "18d2f259130db1bbb89500d26944971a9beeb410de91ff14039203f055d7f9f0"
checksum = "9ffb08ccd8a77fb31cdbbda2afa2333d8f85299b1bc0d1c194259ba66d160d74"
dependencies = [
"cranelift-bitset",
"serde",
@@ -1313,9 +1313,9 @@ dependencies = [
[[package]]
name = "cranelift-frontend"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cf37a38d982d45fe2c065d55e4de76e596b443b6acceb3ca726c2072c8ba6d7b"
checksum = "b447e4f2bb44b1188185a77f478e5a91b7723a40b3b58c3e2d5b26df2ed5a665"
dependencies = [
"cranelift-codegen",
"hashbrown 0.17.1",
@@ -1326,15 +1326,15 @@ dependencies = [
[[package]]
name = "cranelift-isle"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8ce8f84e2d44326879e18016d763457a2cb5d775e4a5822cd7473fc171fca063"
checksum = "2f0989e943f3a9d41989595826bba544df9fda64bcddd4df0c06fb2e26af3cb3"
[[package]]
name = "cranelift-native"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "df64a0392edac7b38fb2965ce8e205e7c5e219e4c531ed3cd1929c782f21853d"
checksum = "5fa10df59e776c42dae5b6ba5216ba5321707a2136abd2219e615c54b234fc1b"
dependencies = [
"cranelift-codegen",
"libc",
@@ -1343,9 +1343,9 @@ dependencies = [
[[package]]
name = "cranelift-srcgen"
version = "0.136.7"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3748e3c77c0717359cd4c089e1dc057221eb8598a9c18b0b5afccb5685975abb"
checksum = "36508559c8839a8b6ee091f9deaa9cfe620a82f1abb5e358a0a0c65290583622"
[[package]]
name = "crc"
@@ -2154,7 +2154,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
dependencies = [
"libc",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -2386,7 +2386,7 @@ checksum = "94e7099f6313ecacbe1256e8ff9d617b75d1bcb16a6fddef94866d225a01a14a"
dependencies = [
"io-lifetimes 2.0.4",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
@@ -5227,7 +5227,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20fd6de4ccfcc187e38bc21cfa543cb5a302cb86a8b114eb7f0bf0dc9f8ac00f"
dependencies = [
"io-lifetimes 3.0.1",
"windows-sys 0.52.0",
"windows-sys 0.60.2",
]
[[package]]
@@ -5265,7 +5265,7 @@ checksum = "3640c1c38b8e4e43584d8df18be5fc6b0aa314ce6ebf51b53313d4306cca8e46"
dependencies = [
"hermit-abi",
"libc",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -7424,9 +7424,9 @@ dependencies = [
[[package]]
name = "pulley-interpreter"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99ecf828c291348e4066f8e45bf37c35ea6012b07a9201e7911c21f03ad1af3e"
checksum = "335e459f9c7809af04768799880504d014d07e8e2fc6ae682fe2a105d8ced33f"
dependencies = [
"cranelift-bitset",
"log",
@@ -7436,9 +7436,9 @@ dependencies = [
[[package]]
name = "pulley-macros"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20e35ece122b2e8bbd7ea9db0709b3d32f20555b73985efc3eaf6afa4ef2ecdf"
checksum = "dd492ac929a6ca0357362d9fa0a09e31290feac5914550ccfb539b21f89c4b9e"
dependencies = [
"proc-macro2",
"quote",
@@ -7968,7 +7968,7 @@ dependencies = [
"errno",
"libc",
"linux-raw-sys",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -8036,7 +8036,7 @@ dependencies = [
"security-framework",
"security-framework-sys",
"webpki-root-certs",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -9783,7 +9783,7 @@ dependencies = [
"getrandom 0.3.4",
"once_cell",
"rustix",
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -11117,9 +11117,9 @@ dependencies = [
[[package]]
name = "wasmtime"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "263d6a66a772efff2c98a1aa367e8e61dae32d2ecf95f85f4776733762322aa7"
checksum = "f32390bdc8d7cdb6259a1b855178bfed88226b4004b209fd48fb30e0deb01cd3"
dependencies = [
"addr2line",
"async-trait",
@@ -11159,9 +11159,9 @@ dependencies = [
[[package]]
name = "wasmtime-environ"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "5f2f0898bedc77f110dca6f70394780f89af68a8ca19e12559ee73d4187a6fe9"
checksum = "9c10f8ef1c9ee5e0f125c775fe56a4d07b8525db30a96e6358c61d93bd11dee4"
dependencies = [
"anyhow",
"cpp_demangle",
@@ -11190,9 +11190,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-component-macro"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b140c28283bd2255a4bb8834621f7200bbe7581cbca91d803b5ba4adf9119a5e"
checksum = "620c53182ebd26c9fff5b90dd53cf8ec3103c381403fd32f8d395da31a9e4a46"
dependencies = [
"anyhow",
"proc-macro2",
@@ -11205,15 +11205,15 @@ dependencies = [
[[package]]
name = "wasmtime-internal-component-util"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "853075a197694ba7f0749e7af78b59e12c0956dff5b16dafbfc49c3b90cdbc93"
checksum = "011e31ca343d9ba0ec623153cd94131b6f03973ef1a0ab791161f642e4a16a93"
[[package]]
name = "wasmtime-internal-core"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e6e13ab3aa598d863643ef9ec043d63fde7effca4465270446d5b868936b27a6"
checksum = "ab15e50a060b746493e6e95ef3ce4e6e7ebfdd7cc336a7dff0f0277e01b447ef"
dependencies = [
"hashbrown 0.17.1",
"libm",
@@ -11222,9 +11222,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-cranelift"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "660103cff91df46f9f06568f3889b8b59a6ae0f56756abfcc002a0a69974cc9f"
checksum = "dc3d27440a83fba26dd2784a997e13d9acb3606a75fb127c324929b52221c5c5"
dependencies = [
"cranelift-codegen",
"cranelift-control",
@@ -11248,9 +11248,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-fiber"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c4d0e958516bdf283b83015283774e11c86b66f2f4bd7d2ea52e9799fa59cddb"
checksum = "6e54b28d0d453ca8932e4504065ae66a78f01fcb22b1a2ee287128d732fa9d6f"
dependencies = [
"cc",
"libc",
@@ -11262,9 +11262,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-jit-debug"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ad61b1e661871bb7d11b5543202a05c44ed8682806b438f68ced629a22719463"
checksum = "9293e75a3048b900f7b7c524702abca16d8a2332f970324eefc519f454cd5d69"
dependencies = [
"cc",
"wasmtime-internal-versioned-export-macros",
@@ -11272,9 +11272,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-jit-icache-coherence"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "52c641b9e1bab449c7316896f01d4a0c426e2a502a5a8098e1af4a0392053e7a"
checksum = "b852e568831b913d410541bb37edc45a5002e472208fbdbaf844ed801dd4255f"
dependencies = [
"libc",
"wasmtime-internal-core",
@@ -11283,9 +11283,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-unwinder"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "03303a9abd333edcbd44fee3b1e0905ad156d3bcec311323d061cdff92e7d1f3"
checksum = "a1f7349c9834a542275ad757340079e6453fccb429efce581454d23f85af92c0"
dependencies = [
"cranelift-codegen",
"log",
@@ -11295,9 +11295,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-versioned-export-macros"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8db0c7f417e5ca3ba92d127d17b980529455d01c141be99204e6d309630c42de"
checksum = "30b3e0768a450d9dea3e16b83f2498f0b08db0e32bad695e35564eef017be3f1"
dependencies = [
"proc-macro2",
"quote",
@@ -11306,9 +11306,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-wit-bindgen"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6292ee4f797f9befb64aa2b3477ec8576501d6302ec21fd2785a8d3f94cf8717"
checksum = "b9d085c540b95d0ffebf98c266e6f152e1acf96a9f676f224a74307b9d422c15"
dependencies = [
"anyhow",
"bitflags 2.13.2",
@@ -11320,9 +11320,9 @@ dependencies = [
[[package]]
name = "wasmtime-wasi"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3175ff29e2992269f51ec372f7757941f11f87b265a614761726960d42ef6e4d"
checksum = "17f8ce6b9e77539b5f52d440346f876a84c513ec1b07162845282f8652f7f7f9"
dependencies = [
"async-trait",
"bitflags 2.13.2",
@@ -11344,9 +11344,9 @@ dependencies = [
[[package]]
name = "wasmtime-wasi-io"
version = "49.0.7"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3bb561839e32b61bf0cdd51efe3874fac5de1bd5775a5b7c41bdf70993e367ea"
checksum = "da9f90eb7ce6edbead27dba3a58843398875defa73b8dce4bbc29d0ce3dc9b40"
dependencies = [
"async-trait",
"bytes",
@@ -11620,7 +11620,7 @@ version = "0.1.11"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c2a7b1c03c876122aa43f3020e6c3c3ee5c05081c9a00739faf7503aeba10d22"
dependencies = [
"windows-sys 0.52.0",
"windows-sys 0.61.2",
]
[[package]]
@@ -11788,6 +11788,15 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.59.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e38bc4d79ed67fd075bcc251a1c39b32a1776bbe92e5bef1f0bf1f8c531853b"
dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "windows-sys"
version = "0.60.2"
@@ -12060,7 +12069,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f3fd376f71958b862e7afb20cfe5a22830e1963462f3a17f49d82a6c1d1f42d"
dependencies = [
"bitflags 2.13.2",
"windows-sys 0.52.0",
"windows-sys 0.59.0",
]
[[package]]
+9 -65
Переглянути файл
@@ -301,30 +301,19 @@ fn finish_launch(
// The module/project JDK, else the JDK the Java language server builds the module with, else one
// matching its Java version.
let project_jdk = ide_sdk::apply::module_jdk(root, module, settings);
// The build model's level includes what the module inherits from its parent POMs.
let release = || {
model
let from_server = info.java_home.as_deref().map(ide_sdk::java::java_executable).filter(|p| p.is_file());
let java = project_jdk.map(|j| ide_sdk::java::java_executable(&j.home)).or(from_server).or_else(|| {
// The build model's level includes what the module inherits from its parent POMs.
let release = model
.maven
.as_ref()
.and_then(|m| m.projects.iter().find(|p| root.join(&p.dir) == module))
.and_then(|p| p.java_version)
.or_else(|| ide_sdk::java::project_java_version(module))
};
let java = match project_jdk {
Some(j) => Some(ide_sdk::java::java_executable(&j.home)),
None => {
let release = release();
let server = info.java_home.as_deref().and_then(|home| server_java(home, release));
match server {
Some(java) => Some(java),
None => {
let jdks = ide_sdk::java::installed_jdks();
info.hints.extend(ide_sdk::java::missing_jdk_message(&jdks, release));
ide_sdk::java::pick_jdk(&jdks, release).map(|j| ide_sdk::java::java_executable(&j.home))
}
}
}
};
.or_else(|| ide_sdk::java::project_java_version(module));
let jdks = ide_sdk::java::installed_jdks();
info.hints.extend(ide_sdk::java::missing_jdk_message(&jdks, release));
ide_sdk::java::pick_jdk(&jdks, release).map(|j| ide_sdk::java::java_executable(&j.home))
});
info.java_exec = Some(java.map(|p| p.to_string_lossy().into_owned()).unwrap_or_else(|| "java".to_owned()));
let exec = PathBuf::from(info.java_exec.as_deref().unwrap_or("java"));
let shorten = ide_run::java_cmdline::shortening_for(&exec, &info.class_paths, &info.module_paths, cfg!(windows));
@@ -339,19 +328,6 @@ fn finish_launch(
}
}
/// The `java` of the JDK a Java language server reports, when it can run classes compiled for
/// `release`: that JDK is the one the server runs on or defaults to, not necessarily one the
/// module's bytecode loads on. A home whose version is unknown is used only when `release` is too.
fn server_java(home: &Path, release: Option<u32>) -> Option<PathBuf> {
match ide_sdk::java::jdk_at(home) {
Some(jdk) if release.is_none_or(|release| jdk.major >= release) => {
Some(ide_sdk::java::java_executable(&jdk.home))
}
Some(_) => None,
None => Some(ide_sdk::java::java_executable(home)).filter(|java| release.is_none() && java.is_file()),
}
}
/// With Settings › Maven › Delegate IDE build/run actions to Maven, javac's verdict replaces
/// JDT's. Classes JDT wrote for sources with errors look up to date to Maven's incremental
/// compiler, so a launch JDT reports errors for recompiles everything.
@@ -581,38 +557,6 @@ fn drop_processor_recreate_errors(info: &mut JavaLaunchInfo) {
mod tests {
use super::*;
fn fake_jdk(dir: &Path, version: Option<&str>) -> PathBuf {
let bin = dir.join("bin");
std::fs::create_dir_all(&bin).unwrap();
std::fs::write(bin.join(if cfg!(windows) { "java.exe" } else { "java" }), "").unwrap();
if let Some(version) = version {
std::fs::write(dir.join("release"), format!("JAVA_VERSION=\"{version}\"\n")).unwrap();
}
dir.to_path_buf()
}
#[test]
fn a_server_jdk_older_than_the_module_release_is_not_used() {
let tmp = tempfile::tempdir().unwrap();
let jdk17 = fake_jdk(&tmp.path().join("17"), Some("17.0.12"));
let jdk21 = fake_jdk(&tmp.path().join("21"), Some("21.0.4"));
let unknown = fake_jdk(&tmp.path().join("unknown"), None);
// (server JDK, module release, used?)
let cases = [
(&jdk17, Some(21), false),
(&jdk17, Some(17), true),
(&jdk17, Some(11), true),
(&jdk17, None, true),
(&jdk21, Some(21), true),
(&unknown, None, true),
(&unknown, Some(21), false),
];
for (home, release, used) in cases {
assert_eq!(server_java(home, release).is_some(), used, "{} for release {release:?}", home.display());
}
assert!(server_java(&tmp.path().join("missing"), None).is_none());
}
#[test]
fn recognises_a_processor_recreating_its_output() {
assert!(processor_recreated_a_file(
-44
Переглянути файл
@@ -46,50 +46,6 @@ test("a narrow diff keeps navigation, settings and the difference count visible"
await expect(toolbar).toContainText("1 of 1 differences");
});
test("combined diff file actions stay visible beside a long name in a narrow pane", async ({ workbench: page }) => {
const longName = "OrderHistoryCustomerNotificationDeliveryPreferencesValidationDefaults.txt";
const directory = "/dev/acme-api/src/main/orders/preferences";
await page.evaluate(
async (paths) => {
const optionsPath = "/src/features/vcs/allInOneDiff.ts";
const inputPath = "/src/features/vcs/diffInput.ts";
const { setAllInOneDiff } = await import(optionsPath);
const { openDiff, withChain } = await import(inputPath);
setAllInOneDiff(true);
await openDiff(
withChain(
paths.map((path) => ({
path,
left: { type: "text", text: "before\n", label: "HEAD" },
right: { type: "worktree" },
})),
0,
),
);
},
[`${directory}/${longName}`, `${directory}/Notes.txt`],
);
await page.setViewportSize({ width: 460, height: 600 });
const file = page.getByRole("region", { name: longName, exact: true });
const header = file.getByRole("button", { name: /^(Collapse|Expand) File$/ }).locator("..");
const open = header.getByRole("button", { name: "Open in Separate Tab", exact: true });
const jump = header.getByRole("button", { name: "Jump to Source", exact: true });
await expect(open).toBeInViewport({ ratio: 1 });
await expect(jump).toBeInViewport({ ratio: 1 });
const label = header.getByText(longName, { exact: true });
await expect(label).toHaveCSS("text-overflow", "ellipsis");
const labelBox = (await label.boundingBox())!;
const jumpBox = (await jump.boundingBox())!;
expect(labelBox.x).toBeGreaterThan(jumpBox.x + jumpBox.width);
await expect(header).toContainText("src/main/orders/preferences");
await header.getByRole("button", { name: "Collapse File", exact: true }).click();
await expect(file.getByRole("button", { name: "Expand File", exact: true })).toBeVisible();
await open.click();
await expect(page.getByRole("tab", { name: new RegExp(longName), selected: true })).toBeVisible();
});
test("maximizes a diff preview tab and restores its previous layout", async ({ workbench: page }) => {
const toolbar = await openChain(page);
const viewer = toolbar.locator("..");
-4
Переглянути файл
@@ -44,8 +44,6 @@ mod windows;
#[cfg(windows)]
mod windows_error_mode;
#[cfg(windows)]
mod windows_webview_keys;
#[cfg(windows)]
mod windows_webview_recovery;
use parking_lot::Mutex;
@@ -142,8 +140,6 @@ pub fn run() {
.plugin(tauri_plugin_notification::init())
.plugin(tauri_plugin_dialog::init());
#[cfg(windows)]
let app = app.plugin(windows_webview_keys::init());
#[cfg(windows)]
let app = app.plugin(windows_webview_recovery::init());
#[cfg(target_os = "linux")]
let app = app.plugin(linux_window_state::plugin());
-32
Переглянути файл
@@ -1,32 +0,0 @@
//! WebView2's browser accelerator keys. A key the IDE keymap leaves alone otherwise reaches
//! WebView2, which runs its browser feature: Ctrl+F in a view without its own find opens the
//! page's Find bar over the whole window, F3 finds the next match there, Ctrl+P prints, F12 opens
//! DevTools. Turning them off leaves every key to the page; editing keys stay with the webview.
use tauri::{Webview, Wry, plugin};
use webview2_com::Microsoft::Web::WebView2::Win32::ICoreWebView2Settings3;
use windows::core::Interface;
pub fn init() -> plugin::TauriPlugin<Wry> {
plugin::Builder::new("webview-keys").on_webview_ready(disable_browser_keys).build()
}
fn disable_browser_keys(webview: Webview) {
let label = webview.label().to_owned();
if let Err(error) = webview.with_webview(move |platform| {
// SAFETY: with_webview runs on the controller's owning STA thread.
let result = unsafe {
platform
.controller()
.CoreWebView2()
.and_then(|core| core.Settings())
.and_then(|settings| settings.cast::<ICoreWebView2Settings3>())
.and_then(|settings| settings.SetAreBrowserAcceleratorKeysEnabled(false))
};
if let Err(error) = result {
tracing::warn!(window = %label, %error, "cannot turn off WebView2 browser keys");
}
}) {
tracing::warn!(window = webview.label(), %error, "cannot access WebView2 controller");
}
}
+4 -30
Переглянути файл
@@ -37,7 +37,6 @@ import { maybeEditorService, type EditorInput } from "@/workbench/contributions"
import { isSameOrInside } from "@/platform/paths";
import { useProject } from "@/platform/project";
import { rootOfPath } from "@/platform/projectRoots";
import { isVirtualUri } from "@/platform/virtualDocs";
import { cornerInset } from "@/editor/core/cm/cornerInset";
export { iconAreaSource, mapLineStart, type IconAreaSource } from "@/editor/core/cm/iconArea";
@@ -789,38 +788,11 @@ export function setLibraryRoots(owner: string, roots: readonly string[]): () =>
}
export function isLibraryPath(path: string): boolean {
if (navigatedLibraryFiles.has(path)) return true;
for (const roots of libraryRoots.values())
for (const r of roots) if (path === r || path.startsWith(r.endsWith("/") ? r : `${r}/`)) return true;
return false;
}
/** Whether `path` lies outside every folder of the open project (or workspace). */
function outsideProject(path: string): boolean {
const project = useProject.getState().project;
if (!project) return false;
const folders = project.workspace ? project.workspace.projects : [project.root];
return !folders.some((root) => isSameOrInside(path, root));
}
/** Files outside the project that code navigation opened: library sources, shown read-only. */
const navigatedLibraryFiles = new Set<string>();
/**
* Opens a code location a language server or the index answered (a declaration, an
* implementation, a documentation link) and selects `selection`. A file outside the project is a
* library source wherever the server keeps it (an SDK, its own cache or bundled stubs, a temporary
* copy), so it opens read-only like the External Libraries' files.
*/
export async function openCodeLocation(
path: string,
selection?: { line: number; col: number },
options: { focus?: boolean } = {},
): Promise<void> {
if (!isVirtualUri(path) && outsideProject(path)) navigatedLibraryFiles.add(path);
await maybeEditorService()?.openFile(path, { selection, focus: options.focus ?? true });
}
/**
* A document outside the project's own code: a server's virtual document (a library class), a
* file under the library roots or in a `node_modules` folder (the library roots list only direct
@@ -834,8 +806,10 @@ export async function openCodeLocation(
*/
export function isLibrarySource(ctx: Pick<EditorDocContext, "path" | "virtual">): boolean {
if (ctx.virtual || isLibraryPath(ctx.path) || /(^|[\\/])node_modules[\\/]/.test(ctx.path)) return true;
if (!useProject.getState().project) return false;
if (outsideProject(ctx.path)) return true;
const project = useProject.getState().project;
if (!project) return false;
const folders = project.workspace ? project.workspace.projects : [project.root];
if (!folders.some((root) => isSameOrInside(ctx.path, root))) return true;
return rootOfPath(ctx.path)?.kind === "excluded";
}
-56
Переглянути файл
@@ -1,56 +0,0 @@
import { beforeEach, describe, expect, it, vi } from "vitest";
const openFile = vi.fn(async () => {});
vi.mock("@/workbench/contributions", async (importOriginal) => ({
...(await importOriginal<typeof import("@/workbench/contributions")>()),
maybeEditorService: () => ({ openFile }),
}));
import { isLibraryPath, isLibrarySource, openCodeLocation } from "./api";
import { useProject } from "@/platform/project";
describe("openCodeLocation", () => {
beforeEach(() => {
openFile.mockClear();
useProject.setState({ project: { root: "/work/app" } as never });
});
// Where language servers keep the library sources they answer with, outside the project.
it.each([
["Java (java-analyzer cache)", "/Users/me/Library/Caches/java-analyzer/sources/src/fe1e/java/util/ArrayList.java"],
["TypeScript (global typescript lib)", "/opt/homebrew/lib/node_modules/typescript/lib/lib.dom.d.ts"],
[
"PHP (Intelephense stubs)",
"/Users/me/Library/Application Support/ide/tools/node_modules/intelephense/lib/stub/standard/standard_2.php",
],
["Kotlin (kotlin-language-server temp copy)", "/private/var/folders/gx/T/kotlinlangserver1146/LocalDate1643.java"],
["Python (interpreter stdlib)", "/Users/me/.pyenv/versions/3.11.5/lib/python3.11/argparse.py"],
])("opens a %s target outside the project as a read-only library source", async (_, path) => {
expect(isLibraryPath(path)).toBe(false);
await openCodeLocation(path, { line: 3, col: 1 });
expect(openFile).toHaveBeenCalledWith(path, { selection: { line: 3, col: 1 }, focus: true });
expect(isLibraryPath(path)).toBe(true);
expect(isLibrarySource({ path, virtual: false })).toBe(true);
});
it("leaves project files and virtual documents editable", async () => {
for (const path of ["/work/app/src/Main.java", "jdt://contents/rt.jar/java.util/ArrayList.class"]) {
await openCodeLocation(path, { line: 0, col: 0 });
expect(isLibraryPath(path)).toBe(false);
}
});
it("does not mark files without an open project", async () => {
useProject.setState({ project: null });
await openCodeLocation("/tmp/elsewhere/notes.txt");
expect(isLibraryPath("/tmp/elsewhere/notes.txt")).toBe(false);
});
it("keeps a workspace's other projects editable", async () => {
useProject.setState({
project: { root: "/work/app", workspace: { projects: ["/work/app", "/work/lib"] } } as never,
});
await openCodeLocation("/work/lib/src/Util.java");
expect(isLibraryPath("/work/lib/src/Util.java")).toBe(false);
});
});
+5 -2
Переглянути файл
@@ -1,5 +1,4 @@
/** React popups for LSP editor features, rendered as a workbench overlay. */
import { openCodeLocation } from "@/editor/api";
import { useEffect, useId, useMemo, useRef, useState, type CSSProperties, type KeyboardEvent } from "react";
import clsx from "clsx";
import {
@@ -23,6 +22,7 @@ import {
T,
} from "@/ui";
import { basename, relativePath, useProject } from "@/platform/project";
import { editorService } from "@/workbench/contributions";
import {
closePopup,
updatePopup,
@@ -564,7 +564,10 @@ function DefinitionPopup({ popup }: { popup: Extract<LspPopup, { kind: "definiti
const targetIcon = (path: string) => fileIconName(basename(path), path);
const open = () => {
closePopup();
void openCodeLocation(location.path, { line: location.range.start.line, col: location.range.start.col });
void editorService().openFile(location.path, {
selection: { line: location.range.start.line, col: location.range.start.col },
focus: true,
});
};
const select = (index: number) =>
updatePopup("definition", { index: (index + popup.targets.length) % popup.targets.length });
+9 -4
Переглянути файл
@@ -6,11 +6,10 @@
* F1's documentation instead of a popup while it is open. The hover's
* documentation is the same view with its own history.
*/
import { openCodeLocation } from "@/editor/api";
import { create, createStore, type StoreApi } from "zustand";
import { commands, nextRequestId, type Location } from "@/platform/ipc";
import { hasPrimaryModifier } from "@/platform/keymap";
import { toolWindowService } from "@/workbench/contributions";
import { editorService, maybeEditorService, toolWindowService } from "@/workbench/contributions";
import { closePopup, updatePopup, useLspPopup, type DocEntry } from "./popupStore";
import { isEmptyMarkup, languageForPath, openDocLink, sourceLink, type DocLinkHandler } from "./markdown";
import { resolveGoRef, signatureRef } from "./docLinks/go";
@@ -145,7 +144,10 @@ export async function editDocSource(host: DocHost): Promise<boolean> {
const loc = (await entry?.source?.().catch(() => null)) ?? null;
if (!loc) return false;
closeHost(host);
await openCodeLocation(loc.path, { line: loc.range.start.line, col: loc.range.start.col });
await editorService().openFile(loc.path, {
selection: { line: loc.range.start.line, col: loc.range.start.col },
focus: true,
});
return true;
}
@@ -197,7 +199,10 @@ async function followTo(host: DocHost, target: DocTarget) {
const h = history(host);
if (!entry || !h) {
closeHost(host);
void openCodeLocation(target.path, { line: target.line, col: target.col });
void maybeEditorService()?.openFile(target.path, {
selection: { line: target.line, col: target.col },
focus: true,
});
return;
}
setHistory(host, pushHistory(h, entry));
+6 -2
Переглянути файл
@@ -5,11 +5,12 @@
* offers to disable hints of that kind.
*/
import { StateEffect, StateField, type Extension } from "@codemirror/state";
import { openCodeLocation, shownAgain } from "@/editor/api";
import { shownAgain } from "@/editor/api";
import { Decoration, EditorView, ViewPlugin, WidgetType, type DecorationSet, type ViewUpdate } from "@codemirror/view";
import { call, commands, isTauri, type InlayHint } from "@/platform/ipc";
import { executeAction } from "@/platform/actions";
import { isNavigationGesture, navigationModifierHeld, onNavigationModifier } from "@/platform/navigationModifier";
import { maybeEditorService } from "@/workbench/contributions";
import { showContextMenu, type MenuItem } from "@/ui";
import { useProject } from "@/platform/project";
import { editorPrefs } from "@/platform/editorSettings";
@@ -83,7 +84,10 @@ class InlayWidget extends WidgetType {
if (e.button !== 0 || !isNavigationGesture(e)) return;
e.preventDefault();
e.stopPropagation();
void openCodeLocation(loc.path, { line: loc.range.start.line, col: loc.range.start.col });
void maybeEditorService()?.openFile(loc.path, {
selection: { line: loc.range.start.line, col: loc.range.start.col },
focus: true,
});
});
}
el.appendChild(span);
+5 -2
Переглянути файл
@@ -6,12 +6,12 @@
* The Markdown parser (marked + DOMPurify, ~40 KB gzip) loads on first use and
* is prefetched when the app goes idle; until then markup shows as plain text.
*/
import { openCodeLocation } from "@/editor/api";
import { useMemo, useSyncExternalStore } from "react";
import { LanguageDescription, type Language } from "@codemirror/language";
import { languages } from "@codemirror/language-data";
import { classHighlighter, highlightTree } from "@lezer/highlight";
import type { Markup } from "@/bindings";
import { maybeEditorService } from "@/workbench/contributions";
import { isTauri } from "@/platform/ipc";
import { onOtherShare } from "@/platform/paths";
import { useProject } from "@/platform/project";
@@ -247,7 +247,10 @@ export function sourceLink(href: string): { path: string; line: number; col: num
export function openDocLink(href: string) {
const target = sourceLink(href);
if (target) {
void openCodeLocation(target.path, { line: target.line, col: target.col });
void maybeEditorService()?.openFile(target.path, {
selection: { line: target.line, col: target.col },
focus: true,
});
} else if (/^https?:\/\//.test(href) && isTauri()) {
void import("@tauri-apps/plugin-opener").then((m) => m.openUrl(href)).catch(() => {});
}
+5 -9
Переглянути файл
@@ -51,11 +51,11 @@ import {
whenSynced,
type ContributedDefinition,
type EditorDocContext,
openCodeLocation,
} from "@/editor/api";
import { structure } from "@/editor/structure";
import { executeAction } from "@/platform/actions";
import { basename, relativePath, useProject } from "@/platform/project";
import { editorService } from "@/workbench/contributions";
import { fileIconName } from "@/ui";
import { NO_SERVER, debounce, docOf, isUnavailable, lspDoc, lspRequest, reportLspError } from "./lsp";
import { offsetToPos, rangeContains, rangeToOffsets } from "./positions";
@@ -108,7 +108,10 @@ import {
const highlightsBackoff = featureBackoff();
export async function navigateTo(loc: Location) {
await openCodeLocation(loc.path, { line: loc.range.start.line, col: loc.range.start.col });
await editorService().openFile(loc.path, {
selection: { line: loc.range.start.line, col: loc.range.start.col },
focus: true,
});
}
const NOT_FOUND: Record<GotoKind, string> = {
@@ -582,13 +585,6 @@ async function gotoResolved(
)
return;
if (superseded()) return;
// ⌘B on a declaration's own name shows its usages also when the server has no definition
// there instead of answering the declaration itself (kotlin-language-server).
if (kind === "definition" && !fromSyntax && (await onDeclarationName(view, offset))) {
if (superseded()) return;
if (!(await executeAction("find.showUsages"))) showHint(view, "No usages found");
return;
}
// The server only resolves what it sees: answer from the project index, which also
// covers attached dependency projects (an unresolved import into them). Never for a
// module path: a segment is not a symbol name.
-25
Переглянути файл
@@ -417,31 +417,6 @@ describe("navigation wiring", () => {
expect(openFile).not.toHaveBeenCalled();
});
it.each([
["kotlin", "class Library {\n fun lend(isbn: String) = isbn\n}\n", 24, "/p/Library.kt", "function_declaration"],
["java", "class A {\n void lend() {}\n}\n", 17, "/p/A.java", "method_declaration"],
["typescript", "class A {}\nfunction lend() {}\n", 20, "/p/a.ts", "function_declaration"],
])(
"shows usages on a %s declaration whose server answers no definition there",
async (language, text, at, path, declaration) => {
// kotlin-language-server answers nothing on a declaration's own name.
cmd.lspGoto.mockReturnValueOnce(ok([]));
const line = text.slice(0, at).split("\n").length - 1;
const col = at - text.lastIndexOf("\n", at - 1) - 1;
cmd.syntaxNodeAt.mockReturnValueOnce(
ok({
node: node("identifier", r(line, col, col + 4), "name"),
ancestors: [node(declaration, r(line, 0, col + 20))],
}),
);
const view = editor(text, language, at, path);
await gotoTargets(view, "definition");
expect(executeAction).toHaveBeenCalledWith("find.showUsages");
expect(cmd.navIndexDefinitions).not.toHaveBeenCalled();
expect(openFile).not.toHaveBeenCalled();
},
);
it("shows usages on a declaration a plugin's index links elsewhere, and follows the link from a call", async () => {
// MyBatis Duo indexes the mapper method's name as a link to its XML statement.
const xml = { path: "/p/UserMapper.xml", range: r(3, 16, 24) };
+5 -2
Переглянути файл
@@ -5,7 +5,7 @@
*/
import { EditorSelection } from "@codemirror/state";
import type { EditorView } from "@codemirror/view";
import { openCodeLocation, activeEditor, editorsFor, whenSynced, type EditorDocContext } from "@/editor/api";
import { activeEditor, editorsFor, whenSynced, type EditorDocContext } from "@/editor/api";
import { docOf, lspRequest } from "@/editor/lsp/lsp";
import { offsetToPos, posToOffset } from "@/editor/lsp/positions";
import { caretAnchor, openPopup } from "@/editor/lsp/popupStore";
@@ -217,7 +217,10 @@ async function gotoRelated(view: EditorView) {
return;
}
const open = (item: (typeof items)[number]) =>
openCodeLocation(item.path, item.line === undefined ? undefined : { line: item.line, col: item.col ?? 0 });
editorService().openFile(item.path, {
selection: item.line === undefined ? undefined : { line: item.line, col: item.col ?? 0 },
focus: true,
});
if (items.length === 1) {
await open(items[0]!);
return;
+2 -3
Переглянути файл
@@ -1,9 +1,8 @@
/** "hierarchy" tool window: call hierarchy (⌃⌥H) and type hierarchy (⌃H). */
import { openCodeLocation } from "@/editor/api";
import { useCallback, useMemo, useRef } from "react";
import { create } from "zustand";
import { basename, relativePath, useProject } from "@/platform/project";
import { useOccurrenceNavigator } from "@/workbench/contributions";
import { maybeEditorService, useOccurrenceNavigator } from "@/workbench/contributions";
import {
EmptyState,
IconButton,
@@ -165,7 +164,7 @@ export function HierarchyView() {
};
const show = (n: Node, focus: boolean) => {
const t = targetOf(n);
if (t) void openCodeLocation(t.path, { line: t.line, col: t.col }, { focus });
if (t) void maybeEditorService()?.openFile(t.path, { selection: { line: t.line, col: t.col }, focus });
};
// Every node is an occurrence, as in IDEA's hierarchy views.
+2 -3
Переглянути файл
@@ -2,7 +2,6 @@
* "usages" tool window: Find Usages results grouped by file with line
* previews, one tab per search (pinnable, as the Find tool window's tabs).
*/
import { openCodeLocation } from "@/editor/api";
import { useCallback, useLayoutEffect, useMemo, useRef, useState, type KeyboardEvent, type ReactNode } from "react";
import clsx from "clsx";
import { create } from "zustand";
@@ -12,7 +11,7 @@ import { useEditorPrefs } from "@/platform/editorSettings";
import { BUNDLED_MONO_FAMILY, monoFontFamily } from "@/platform/fonts";
import { shortcutLabel } from "@/platform/keymap";
import { basename, relativeDir, useProject } from "@/platform/project";
import { useOccurrenceNavigator } from "@/workbench/contributions";
import { maybeEditorService, useOccurrenceNavigator } from "@/workbench/contributions";
import {
EmptyState,
Icon,
@@ -144,7 +143,7 @@ export function toggleExcludedUsages(excluded: ReadonlySet<string>, usages: read
}
function openUsage(u: Usage, focus: boolean) {
void openCodeLocation(u.path, { line: u.line, col: u.col }, { focus });
void maybeEditorService()?.openFile(u.path, { selection: { line: u.line, col: u.col }, focus });
}
export function UsagesView() {
+1 -2
Переглянути файл
@@ -1,5 +1,4 @@
/** IPC helpers shared by the code-insight views. */
import { openCodeLocation } from "@/editor/api";
import type { EditorView } from "@codemirror/view";
import { activeEditor, editorsFor, whenSynced } from "@/editor/api";
import { isVirtualUri, virtualDocument } from "@/platform/virtualDocs";
@@ -145,5 +144,5 @@ export async function withDocument<T>(path: string, fn: (doc: number) => Promise
}
export function openLocation(path: string, line: number, col: number): Promise<void> {
return openCodeLocation(path, { line, col });
return maybeEditorService()?.openFile(path, { selection: { line, col }, focus: true }) ?? Promise.resolve();
}
+15 -54
Переглянути файл
@@ -8,24 +8,24 @@
}
.toolbar {
flex: none;
height: var(--h-header);
display: flex;
align-items: center;
gap: var(--space-0-5);
padding: var(--space-1) 10px;
padding: 0 6px;
border-bottom: 1px solid var(--border);
}
.toolbar > * {
flex-shrink: 0;
}
.sep {
flex: none;
width: 1px;
height: 14px;
margin-inline: var(--space-1);
margin: 0 4px;
background: var(--border-strong);
}
.count {
min-width: 0;
margin-inline: var(--space-1-5);
overflow: hidden;
text-overflow: ellipsis;
padding: 0 6px;
color: var(--fg-subtle);
font-size: var(--fs-small);
white-space: nowrap;
@@ -37,15 +37,9 @@
flex: 1;
min-height: 0;
overflow-y: auto;
padding: var(--space-2) var(--space-3);
}
.block {
border: 1px solid var(--border);
border-radius: var(--radius-popup-large);
background: var(--bg-editor);
}
.block + .block {
margin-top: 10px;
border-bottom: 1px solid var(--border);
}
/* The file's header stays at the top while its diff scrolls by. */
.header {
@@ -55,47 +49,27 @@
display: flex;
align-items: center;
gap: var(--space-1);
padding: var(--space-3) 10px;
background: var(--bg-editor);
height: var(--h-header);
padding: 0 6px;
background: var(--bg-elev);
border-bottom: 1px solid var(--border);
border-start-start-radius: inherit;
border-start-end-radius: inherit;
font-size: var(--fs-ui);
}
.block[data-collapsed] .header {
border-radius: inherit;
border-bottom: 0;
}
.file {
display: flex;
align-items: center;
gap: var(--space-1-5);
min-width: 0;
flex: 1;
}
.file > svg {
.name {
flex: none;
font-weight: 500;
white-space: nowrap;
}
.name,
.dir {
min-width: 0;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
}
.name {
font-weight: 600;
}
.dir {
flex: 1;
color: var(--fg-subtle);
font-size: var(--fs-small);
}
.body {
display: flex;
flex-direction: column;
overflow: hidden;
border-end-start-radius: inherit;
border-end-end-radius: inherit;
}
.body[hidden] {
display: none;
@@ -110,16 +84,3 @@
justify-content: center;
color: var(--fg-subtle);
}
:global(:root[data-compact]) .toolbar {
padding-block: 1px;
}
:global(:root[data-compact]) .scroll {
padding: var(--space-1) var(--space-1-5);
}
:global(:root[data-compact]) .header {
padding-block: 7px;
}
:global(:root[data-compact]) .block + .block {
margin-top: var(--space-1);
}
+12 -19
Переглянути файл
@@ -63,13 +63,7 @@ function Block({
const root = useProject((s) => s.project?.root ?? "");
const dir = relativeDir(root, item.path);
return (
<section
ref={ref}
className={styles.block}
data-combined-block={item.path}
data-collapsed={collapsed || undefined}
aria-label={name}
>
<section ref={ref} className={styles.block} data-combined-block={item.path} aria-label={name}>
<div className={styles.header}>
<IconButton
icon={collapsed ? "chevron-right" : "chevron-down"}
@@ -78,6 +72,16 @@ function Block({
aria-expanded={!collapsed}
onClick={onToggle}
/>
<Icon name={fileIconName(name)} size={16} />
<span className={styles.name} style={{ color: KIND_COLOR[kind] }} title={tx(KIND_LABEL[kind])}>
{name}
</span>
{dir && (
<span className={styles.dir} title={item.path}>
{dir}
</span>
)}
<span className={styles.grow} />
<IconButton
icon="diff"
title="Open in Separate Tab"
@@ -93,14 +97,6 @@ function Block({
onClick={() => void editorService().openFile(item.path, { focus: true })}
/>
)}
<span className={styles.sep} aria-hidden="true" />
<div className={styles.file} title={`${item.path}\n${tx(KIND_LABEL[kind])}`}>
<Icon name={fileIconName(name)} size={16} />
<span className={styles.name} style={{ color: KIND_COLOR[kind] }}>
{name}
</span>
{dir && <span className={styles.dir}>{dir}</span>}
</div>
</div>
{/* A collapsed block keeps its loaded diff, hidden: unmounting it would release the
working-tree document and, with autosave off, drop its unsaved edits. */}
@@ -133,10 +129,7 @@ export function CombinedDiffTab({ input }: { input: EditorInput }) {
const scrollTo = (path: string) => {
const el = blocks().find((b) => b.dataset.combinedBlock === path);
const scroller = scrollRef.current;
if (el && scroller) {
const inset = Number.parseFloat(getComputedStyle(scroller).paddingTop) || 0;
scroller.scrollTop += el.getBoundingClientRect().top - scroller.getBoundingClientRect().top - inset;
}
if (el && scroller) scroller.scrollTop += el.getBoundingClientRect().top - scroller.getBoundingClientRect().top;
};
const step = (dir: 1 | -1) => {
const next = items[current() + dir];