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

...
Автор SHA1 Повідомлення Дата
l0ng-ai c67771aabb fix(languages): run a language server set to a .jar with java -jar
Settings › Language Servers took a path to a runnable jar (a locally built
groovy-language-server-all.jar) as the executable, so the server never started.
A .jar command now runs as java -jar <jar> <args>, on the project JDK's java
when one is set.
2026-11-19 17:39:19 +08:00
Deng Liuтаdengliu 7e2e2e6cc9 feat(agents): colocate effort and context settings (#4382)
Effort moves into the model popup, next to context size and model settings, with the current effort shown on the model chip (Atlas · Gentle), as Codex and Copilot keep it in the model picker. Up to four levels use the segmented control, more (Codex has six) a dropdown row; the chip's effort/context detail stays visible in the narrow composer layout, where the model name truncates first.

Co-authored-by: dengliu <[email protected]>
2026-11-19 17:36:23 +08:00
Mamaev Igor de73495ab0 fix(vim): support the clipboard option and +=/-=/^= operators in .ideavimrc (#4318)
#4136 added the clipboard option with += only. The rc parser and engine now also take Vim's -= (remove an item / subtract) and ^= (prepend / multiply) for comma-list and number options, clipboard gets its cb alias, and the Vim guide documents the clipboard option.

Co-authored-by: pxc1984 <[email protected]>
2026-11-19 17:32:41 +08:00
l0ng-ai 6c848b9a43 fix(database): connect without TLS when a Prefer handshake fails (#4473)
With SSL mode Prefer, a MySQL/PostgreSQL server whose TLS handshake fails (e.g. TLS 1.0/1.1 only) failed with "received fatal alert: HandshakeFailure", since sqlx only skips TLS when the server doesn't offer it. Prefer now retries once without TLS after a failed handshake (sqlx::Error::Tls or an I/O error carrying a rustls error), as libpq's sslmode=prefer does; the pool keeps the plain options. Fixes #4447
2026-11-19 17:30:57 +08:00
l0ng-ai 4812adba97 fix(deps): update wasmtime to 49.0.6 for RUSTSEC-2026-0571/0572/0573 (#4472)
cargo deny reported three wasmtime advisories (RUSTSEC-2026-0571/0572/0573). wasmtime, wasmtime-wasi and their internal crates move from 49.0.5 to 49.0.6, the patch release with the fixes.
2026-11-19 17:28:27 +08:00
17 змінених файлів з 377 додано та 165 видалено

No files matched your search

Створено
+59 -59
Переглянути файл
@@ -1203,27 +1203,27 @@ dependencies = [
[[package]]
name = "cranelift-assembler-x64"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "249a61efca6a54425e027f5704a6f68a0232b4df527e05a3ef947d89dbdcb078"
checksum = "aecefa88696b62f833cc0c997d19c93246b0268e2aaf23e0e8692e527f6de088"
dependencies = [
"cranelift-assembler-x64-meta",
]
[[package]]
name = "cranelift-assembler-x64-meta"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d5336a46e05db2d515440b1ce8a9363e7bc04b608c0f66cc98dddc5492a66fbf"
checksum = "1391a2546f5edf06a0ff5e9430d73c2713fd536aefec53200dc21846d1467f53"
dependencies = [
"cranelift-srcgen",
]
[[package]]
name = "cranelift-bforest"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "01b3675b13214270fddbd257d5fbf4109be8b02d92fc636fe96e2829514a7235"
checksum = "9528915fbc2c950702329e08c6d72aaff8ece9b7ecdbd225742825c09a445227"
dependencies = [
"cranelift-entity",
"wasmtime-internal-core",
@@ -1231,9 +1231,9 @@ dependencies = [
[[package]]
name = "cranelift-bitset"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d7c1d67aa02b6e174bd2b165c113e94af9498fcc20e2892d0f4d5ab8c9618d09"
checksum = "9dd69a6db85c1bcff989809e0e0b3b06506425f32b545c46aeafda5fe7775d6a"
dependencies = [
"serde",
"serde_derive",
@@ -1242,9 +1242,9 @@ dependencies = [
[[package]]
name = "cranelift-codegen"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "26fe6f3ec5344c32602c414e986dcbe699fa501a3e3e7b02f887d9d12b14ae42"
checksum = "24c2db6c26cd96393cf785c4b51b900738963cc7422aa0045416a7641ae2f6cd"
dependencies = [
"bumpalo",
"cranelift-assembler-x64",
@@ -1273,9 +1273,9 @@ dependencies = [
[[package]]
name = "cranelift-codegen-meta"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "96c5e6323d458486d95781defdb5016a1176fc911d8bc8e64b696adbda6e9044"
checksum = "e284270142e7f1dcb73a992a62a8b3716b4062a65a52d8f2732c6ebf6f7f342f"
dependencies = [
"cranelift-assembler-x64-meta",
"cranelift-codegen-shared",
@@ -1286,24 +1286,24 @@ dependencies = [
[[package]]
name = "cranelift-codegen-shared"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f1260aa93b0bd48e8e55c1c7fd9ff6a260f1a1bc46e1f0151a5055b124e5b15d"
checksum = "6595667b7d505cf85d5bdd014e6f57ad6128183238f8e372319d9384782472f5"
[[package]]
name = "cranelift-control"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "50c179632a09850f81f1a1e9116cb09330c734a86689f3ee4c3f4ec81543acbd"
checksum = "f26ffdbfcd24c3833d730849e6d132af34a400a2b89b44446015c01eecbea21d"
dependencies = [
"arbitrary",
]
[[package]]
name = "cranelift-entity"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d8c071188cb1c3b1803e23ae415a8d5f58d741d3a4b26a79b83dd61921112eac"
checksum = "9ffb08ccd8a77fb31cdbbda2afa2333d8f85299b1bc0d1c194259ba66d160d74"
dependencies = [
"cranelift-bitset",
"serde",
@@ -1313,9 +1313,9 @@ dependencies = [
[[package]]
name = "cranelift-frontend"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e2b85ba0a55d7685117b275fe6f36c819d438862e4223d28f0b97902460ff0ac"
checksum = "b447e4f2bb44b1188185a77f478e5a91b7723a40b3b58c3e2d5b26df2ed5a665"
dependencies = [
"cranelift-codegen",
"hashbrown 0.17.1",
@@ -1326,15 +1326,15 @@ dependencies = [
[[package]]
name = "cranelift-isle"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20ed364edcaed769da7b2709d540f8f7d0ff257749ba193f475e22dba6a0178b"
checksum = "2f0989e943f3a9d41989595826bba544df9fda64bcddd4df0c06fb2e26af3cb3"
[[package]]
name = "cranelift-native"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "418d98c3dce08f0d13526692bbd1888bff4c5f45207f5093d168b5a224fbc88c"
checksum = "5fa10df59e776c42dae5b6ba5216ba5321707a2136abd2219e615c54b234fc1b"
dependencies = [
"cranelift-codegen",
"libc",
@@ -1343,9 +1343,9 @@ dependencies = [
[[package]]
name = "cranelift-srcgen"
version = "0.136.5"
version = "0.136.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4f016b9994e39cad68107f33fa5b8dcee8fb7e38332bde3f97690e5e8abe1b10"
checksum = "36508559c8839a8b6ee091f9deaa9cfe620a82f1abb5e358a0a0c65290583622"
[[package]]
name = "crc"
@@ -7403,9 +7403,9 @@ dependencies = [
[[package]]
name = "pulley-interpreter"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1d74df9e20cba0f6dd07f01c3140535a6b23e40aecccfcacfb921621b41d0acb"
checksum = "335e459f9c7809af04768799880504d014d07e8e2fc6ae682fe2a105d8ced33f"
dependencies = [
"cranelift-bitset",
"log",
@@ -7415,9 +7415,9 @@ dependencies = [
[[package]]
name = "pulley-macros"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8415513bfa407c06de6f11dbe9437f2352e075a5520ff491a131166d3d90aed1"
checksum = "dd492ac929a6ca0357362d9fa0a09e31290feac5914550ccfb539b21f89c4b9e"
dependencies = [
"proc-macro2",
"quote",
@@ -9759,7 +9759,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32497e9a4c7b38532efcdebeef879707aa9f794296a4f0244f6f69e9bc8574bd"
dependencies = [
"fastrand",
"getrandom 0.4.3",
"getrandom 0.3.4",
"once_cell",
"rustix",
"windows-sys 0.61.2",
@@ -11096,9 +11096,9 @@ dependencies = [
[[package]]
name = "wasmtime"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d45bf3b13781b9febb0eef42e1e145146c92ef891f345fd918e0e0fa1568c992"
checksum = "f32390bdc8d7cdb6259a1b855178bfed88226b4004b209fd48fb30e0deb01cd3"
dependencies = [
"addr2line",
"async-trait",
@@ -11138,9 +11138,9 @@ dependencies = [
[[package]]
name = "wasmtime-environ"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "833f00f3dc6128159284c5b71e211f24c97d45e052230a14f767fd830a6fb8b0"
checksum = "9c10f8ef1c9ee5e0f125c775fe56a4d07b8525db30a96e6358c61d93bd11dee4"
dependencies = [
"anyhow",
"cpp_demangle",
@@ -11169,9 +11169,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-component-macro"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0d69c34412409072d2e8ec399101524c330e334ff313f77415e6984cc9c6a172"
checksum = "620c53182ebd26c9fff5b90dd53cf8ec3103c381403fd32f8d395da31a9e4a46"
dependencies = [
"anyhow",
"proc-macro2",
@@ -11184,15 +11184,15 @@ dependencies = [
[[package]]
name = "wasmtime-internal-component-util"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b168d39f2d6b896d89fe096afa4ccdd7a8e927b01469b590af84f02fca3126a1"
checksum = "011e31ca343d9ba0ec623153cd94131b6f03973ef1a0ab791161f642e4a16a93"
[[package]]
name = "wasmtime-internal-core"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ad86a65d12c6a9202584ceb658c9a20cf5b25c32eed61c9be5e5f863f88f0d9"
checksum = "ab15e50a060b746493e6e95ef3ce4e6e7ebfdd7cc336a7dff0f0277e01b447ef"
dependencies = [
"hashbrown 0.17.1",
"libm",
@@ -11201,9 +11201,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-cranelift"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a71f0fd1dd40e4e18d4a20cdba29ff8e0eb2c0f21b12c2eb5869e0fea789dd05"
checksum = "dc3d27440a83fba26dd2784a997e13d9acb3606a75fb127c324929b52221c5c5"
dependencies = [
"cranelift-codegen",
"cranelift-control",
@@ -11227,9 +11227,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-fiber"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "fa4dfa39e58735b24ce3d28bfc8c2b3041603cc8a941bb268395351beff90172"
checksum = "6e54b28d0d453ca8932e4504065ae66a78f01fcb22b1a2ee287128d732fa9d6f"
dependencies = [
"cc",
"libc",
@@ -11241,9 +11241,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-jit-debug"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2eb98d4486c7b0163447d77dea06f3cc87e5e5ba5fc93613f8ec42e27ea181d"
checksum = "9293e75a3048b900f7b7c524702abca16d8a2332f970324eefc519f454cd5d69"
dependencies = [
"cc",
"wasmtime-internal-versioned-export-macros",
@@ -11251,9 +11251,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-jit-icache-coherence"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "852cae234735d79db6c58fe0d04b32f4078ad01fdb3fd6d488ac366132ba9785"
checksum = "b852e568831b913d410541bb37edc45a5002e472208fbdbaf844ed801dd4255f"
dependencies = [
"libc",
"wasmtime-internal-core",
@@ -11262,9 +11262,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-unwinder"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b9289378c82b9db7e7cf933d6bb441ad968536ac48f3f38c55b7cf9d3e8d87e1"
checksum = "a1f7349c9834a542275ad757340079e6453fccb429efce581454d23f85af92c0"
dependencies = [
"cranelift-codegen",
"log",
@@ -11274,9 +11274,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-versioned-export-macros"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc5c60c732d99dbcc5d670b71ba6ccf2b015cd16fc828990eaad2c4b8805ebdb"
checksum = "30b3e0768a450d9dea3e16b83f2498f0b08db0e32bad695e35564eef017be3f1"
dependencies = [
"proc-macro2",
"quote",
@@ -11285,9 +11285,9 @@ dependencies = [
[[package]]
name = "wasmtime-internal-wit-bindgen"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c77e4fcc7cd22772578458c5e233df47190ebc9b8b65788797d99a02787c9000"
checksum = "b9d085c540b95d0ffebf98c266e6f152e1acf96a9f676f224a74307b9d422c15"
dependencies = [
"anyhow",
"bitflags 2.13.2",
@@ -11299,9 +11299,9 @@ dependencies = [
[[package]]
name = "wasmtime-wasi"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "705b90d1fa1084cc73df656868948da77711b97f6b895d145a4949f86bcea674"
checksum = "17f8ce6b9e77539b5f52d440346f876a84c513ec1b07162845282f8652f7f7f9"
dependencies = [
"async-trait",
"bitflags 2.13.2",
@@ -11323,9 +11323,9 @@ dependencies = [
[[package]]
name = "wasmtime-wasi-io"
version = "49.0.5"
version = "49.0.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f3d2b6a255be488639f450b380e7e0923789f946de3463696cd30f2fe8a65cc3"
checksum = "da9f90eb7ce6edbead27dba3a58843398875defa73b8dce4bbc29d0ce3dc9b40"
dependencies = [
"async-trait",
"bytes",
+45 -8
Переглянути файл
@@ -248,6 +248,17 @@ fn legacy_eof(e: &sqlx::Error) -> bool {
matches!(e, sqlx::Error::Protocol(msg) if msg.starts_with("OK_Packet too short"))
}
/// A TLS handshake that failed, e.g. with a server limited to TLS 1.0/1.1. SSL mode Prefer means
/// TLS when it works, else a plain connection, as libpq's `sslmode=prefer` and MySQL clients'
/// PREFERRED do; sqlx only goes plain when the server offers no TLS, so such errors are retried.
fn tls_failed(e: &sqlx::Error) -> bool {
match e {
sqlx::Error::Tls(_) => true,
sqlx::Error::Io(io) => io.get_ref().is_some_and(|inner| inner.is::<rustls::Error>()),
_ => false,
}
}
pub(crate) fn db_err(e: sqlx::Error) -> IdeError {
match &e {
sqlx::Error::Database(d) => {
@@ -832,9 +843,17 @@ impl Pool {
if let Some(n) = setup.statement_cache {
opts = opts.statement_cache_capacity(n);
}
let manager = PgManager { options: opts, init: init.clone(), timeout };
let mut manager = PgManager { options: opts, init: init.clone(), timeout };
// Open once directly so authentication failures retain their database error.
let first = manager.connect().await.map_err(db_err)?;
let first = match manager.connect().await {
Err(e) if source.ssl == DbSslMode::Prefer && tls_failed(&e) => {
tracing::info!("TLS handshake failed, connecting without TLS (SSL mode Prefer): {e}");
manager.options = manager.options.clone().ssl_mode(PgSslMode::Disable);
manager.connect().await
}
first => first,
}
.map_err(db_err)?;
let pool = Bb8Pool::builder().max_size(MAX).connection_timeout(timeout).build_unchecked(manager);
let _ = pool.add(first);
Ok(Pool::Postgres(ServerPool { inner: pool, closed: AtomicBool::new(false) }))
@@ -883,14 +902,19 @@ impl Pool {
}
let mut manager = MysqlManager { options: opts, init: init.clone(), timeout };
// Open once directly so authentication failures retain their database error.
let first = match manager.connect().await {
Err(e) if legacy_eof(&e) => {
manager.options = manager.options.clone().deprecate_eof(false);
manager.connect().await
let mut first = manager.connect().await;
if source.ssl == DbSslMode::Prefer && first.as_ref().is_err_and(tls_failed) {
if let Err(e) = &first {
tracing::info!("TLS handshake failed, connecting without TLS (SSL mode Prefer): {e}");
}
first => first,
manager.options = manager.options.clone().ssl_mode(MySqlSslMode::Disabled);
first = manager.connect().await;
}
.map_err(db_err)?;
if first.as_ref().is_err_and(legacy_eof) {
manager.options = manager.options.clone().deprecate_eof(false);
first = manager.connect().await;
}
let first = first.map_err(db_err)?;
let pool = Bb8Pool::builder().max_size(MAX).connection_timeout(timeout).build_unchecked(manager);
let _ = pool.add(first);
Ok(Pool::Mysql(ServerPool { inner: pool, closed: AtomicBool::new(false) }))
@@ -1406,6 +1430,19 @@ mod tests {
use super::*;
use crate::source::{DbOptions, DbProperty};
#[test]
fn prefer_retries_without_tls_only_after_a_failed_handshake() {
use std::io;
// What a server limited to old TLS versions gives: rustls's alert inside the I/O error.
let alert = rustls::Error::AlertReceived(rustls::AlertDescription::HandshakeFailure);
assert!(tls_failed(&sqlx::Error::Io(io::Error::new(io::ErrorKind::InvalidData, alert))));
assert!(tls_failed(&sqlx::Error::Tls("bad config".into())));
// Unreachable servers, protocol errors and wrong passwords keep their error.
assert!(!tls_failed(&sqlx::Error::Io(io::ErrorKind::ConnectionRefused.into())));
assert!(!tls_failed(&sqlx::Error::Io(io::Error::new(io::ErrorKind::InvalidData, "eof"))));
assert!(!tls_failed(&sqlx::Error::Protocol("OK_Packet too short".into())));
}
fn sqlserver_debug(ssl: DbSslMode) -> String {
let mut config = tiberius::Config::new();
apply_sqlserver_ssl(&mut config, ssl);
+13
Переглянути файл
@@ -1107,6 +1107,13 @@ pub fn configure_server(cfg: &mut LanguageServerConfig, root: &Path, server_root
}
cfg.command = custom.to_string_lossy().into_owned();
}
// `java -jar` servers run on the project JDK when there is one, like JAR Application runs.
if cfg.command == "java"
&& let Some(java) =
project_jdk(root, s).map(|jdk| crate::java::java_executable(&jdk.home)).filter(|j| j.is_file())
{
cfg.command = java.to_string_lossy().into_owned();
}
let name = cfg.name.clone();
let name = name.as_str();
@@ -1535,6 +1542,12 @@ pub fn server_launch_overrides(cfg: &mut LanguageServerConfig, s: &Settings) {
if let Some(args) = &ls.args {
cfg.args = args.clone();
}
// A server shipped as a runnable jar (groovy-language-server-all.jar) runs on `java -jar`;
// `configure_server` then picks the project JDK's `java`.
if Path::new(&cfg.command).extension().is_some_and(|e| e.eq_ignore_ascii_case("jar")) {
let jar = std::mem::replace(&mut cfg.command, "java".to_owned());
cfg.args.splice(0..0, ["-jar".to_owned(), jar]);
}
}
/// Environment, features, `initializationOptions` and `workspace/configuration`
+28
Переглянути файл
@@ -1272,6 +1272,34 @@ fn language_server_settings_disable_add_and_override() {
assert_eq!(parsed.code_action_kinds, Some(vec!["refactor".to_string()]));
}
#[test]
fn a_server_path_to_a_jar_runs_with_java_jar() {
use crate::apply::server_launch_overrides;
use ide_core::settings::LanguageServerSettings;
let mut s = Settings::default();
let jar = "/opt/groovy/build/libs/groovy-language-server-all.JAR";
s.language_servers.insert(
"groovy-language-server".into(),
LanguageServerSettings { command: jar.into(), args: Some(vec!["--verbose".into()]), ..Default::default() },
);
let mut groovy = server("groovy-language-server");
server_launch_overrides(&mut groovy, &s);
assert_eq!(groovy.command, "java");
assert_eq!(groovy.args, ["-jar", jar, "--verbose"]);
// A project JDK is the one that runs it.
let tmp = tempfile::tempdir().unwrap();
let home = tmp.path().join("jdk");
let java = crate::java::java_executable(&home);
std::fs::create_dir_all(java.parent().unwrap()).unwrap();
std::fs::write(&java, "").unwrap();
std::fs::write(home.join("release"), "JAVA_VERSION=\"21.0.2\"\n").unwrap();
s.languages.java.jdk = home.to_string_lossy().into_owned();
configure_server(&mut groovy, tmp.path(), tmp.path(), &s);
assert!(groovy.command.ends_with(&*Path::new("jdk").join(java.strip_prefix(&home).unwrap()).to_string_lossy()));
assert!(Path::new(&groovy.command).is_file(), "{}", groovy.command);
}
#[test]
fn ruff_configuration_directory_resolves_files_and_validates_pyproject() {
let tmp = tempfile::tempdir().unwrap();
+9 -7
Переглянути файл
@@ -37,13 +37,15 @@ After editing the file, run **Reload .ideavimrc** (from the status bar widget or
Supported lines:
| Line | Notes |
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `map`, `noremap` and their `n`, `v`, `x`, `i`, `o` variants (`nnoremap`, `vmap`…) | `<silent>`, `<unique>`, `<nowait>`, `<buffer>`, `<expr>` and `<script>` flags are accepted and ignored. Key names such as `<esc>` and `<CR>` are case-insensitive. |
| `let mapleader = "…"` | Also `g:mapleader`. `"\<Space>"` and `" "` both mean Space. The default leader is `\`. |
| `set …` | Only the options codemirror-vim implements: `textwidth` (`tw`), `pcre`, `insertModeEscKeysTimeout` and `langmap` (`lmap`). Other options are reported as ignored. |
| `source <file>` | Reads another file by the same rules. `~` is your home directory. |
| `" comment` | Ignored. |
| Line | Notes |
| --------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `map`, `noremap` and their `n`, `v`, `x`, `i`, `o` variants (`nnoremap`, `vmap`…) | `<silent>`, `<unique>`, `<nowait>`, `<buffer>`, `<expr>` and `<script>` flags are accepted and ignored. Key names such as `<esc>` and `<CR>` are case-insensitive. |
| `let mapleader = "…"` | Also `g:mapleader`. `"\<Space>"` and `" "` both mean Space. The default leader is `\`. |
| `set …` | `textwidth` (`tw`), `pcre`, `insertModeEscKeysTimeout`, `langmap` (`lmap`) and `clipboard` (`cb`). `+=`, `-=` and `^=` work as in Vim. Other options are reported as ignored. |
| `source <file>` | Reads another file by the same rules. `~` is your home directory. |
| `" comment` | Ignored. |
`set clipboard+=unnamedplus` (or `unnamed`) also copies yanks, deletes and changes without a register to the system clipboard. The `"+` register always reads and writes the system clipboard.
Anything else (functions, `if`, `autocmd`, plugin commands) is reported as ignored and never executed.
+9 -7
Переглянути файл
@@ -37,13 +37,15 @@ Vim 模式开启时(如果上次是开启状态,启动时也会),OpenIDE
支持的写法:
| 写法 | 说明 |
| ------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `map`、`noremap` 以及它们的 `n`、`v`、`x`、`i`、`o` 变体(`nnoremap`、`vmap`…) | `<silent>`、`<unique>`、`<nowait>`、`<buffer>`、`<expr>`、`<script>` 标志可以写,但会被忽略。`<esc>`、`<CR>` 等键名不区分大小写。 |
| `let mapleader = "…"` | 也可以写 `g:mapleader`。`"\<Space>"` 和 `" "` 都表示空格。默认 leader 是 `\`。 |
| `set …` | 只支持 codemirror-vim 实现的选项:`textwidth`(`tw`)、`pcre`、`insertModeEscKeysTimeout` 和 `langmap`(`lmap`)。其他选项会被标记为已忽略。 |
| `source <file>` | 按同样的规则读取另一个文件,`~` 表示主目录。 |
| `" 注释` | 忽略。 |
| 写法 | 说明 |
| ------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| `map`、`noremap` 以及它们的 `n`、`v`、`x`、`i`、`o` 变体(`nnoremap`、`vmap`…) | `<silent>`、`<unique>`、`<nowait>`、`<buffer>`、`<expr>`、`<script>` 标志可以写,但会被忽略。`<esc>`、`<CR>` 等键名不区分大小写。 |
| `let mapleader = "…"` | 也可以写 `g:mapleader`。`"\<Space>"` 和 `" "` 都表示空格。默认 leader 是 `\`。 |
| `set …` | `textwidth`(`tw`)、`pcre`、`insertModeEscKeysTimeout`、`langmap`(`lmap`)和 `clipboard`(`cb`)。`+=`、`-=`、`^=` 与 Vim 相同。其他选项会被标记为已忽略。 |
| `source <file>` | 按同样的规则读取另一个文件,`~` 表示主目录。 |
| `" 注释` | 忽略。 |
`set clipboard+=unnamedplus`(或 `unnamed`)让不指定寄存器的复制、删除和修改也写入系统剪贴板。`"+` 寄存器始终读写系统剪贴板。
其他内容(函数、`if`、`autocmd`、插件命令等)都会被标记为已忽略,不会执行。
+13 -10
Переглянути файл
@@ -219,11 +219,12 @@ function history(page: Page) {
function modelButton(page: Page) {
return page.getByRole("button", { name: "Model", exact: true }).filter({ visible: true });
}
function effortButton(page: Page) {
return page.getByRole("button", { name: "Reasoning", exact: true }).filter({ visible: true });
/** The effort is shown on the model button, after the model's name. */
function effortLabel(page: Page) {
return modelButton(page).locator("[class*='modelDetail']");
}
async function expectEffort(page: Page, name: string) {
await expect(effortButton(page)).toHaveText(name);
await expect(effortLabel(page)).toHaveText(name);
}
async function selected(box: Locator) {
return box.evaluate((element) => {
@@ -364,8 +365,8 @@ test("Settings and effort popup exclude the agent shortcut", async ({ workbench:
await expect(search).toBeFocused();
await expect(search).toHaveValue("keymap");
await settings.getByRole("button", { name: "Cancel", exact: true }).click();
await effortButton(page).click();
const popup = page.getByRole("listbox", { name: "Reasoning", exact: true });
await modelButton(page).click();
const popup = page.getByRole("radiogroup", { name: "Effort Level", exact: true });
await expect(popup).toBeVisible();
await page.keyboard.press("Alt+t");
expect(await ipcCalls(page, "agent_set_config")).toEqual([]);
@@ -584,14 +585,16 @@ test("New Task discovers uncached model effort before the first prompt", async (
.poll(async () => (await ipcCalls(page, "agent_refresh_models")).filter((call) => call.model === "swift"))
.toEqual([{ provider: provider.id, force: false, model: "swift" }]);
await expect(page.getByRole("status").filter({ hasText: "Loading model settings…" })).toBeVisible();
await expect(effortButton(page)).toHaveCount(0);
await expect(effortLabel(page)).toHaveCount(0);
await page.screenshot({ path: testInfo.outputPath("model-settings-loading.png") });
await page.evaluate(() => document.dispatchEvent(new Event("test:model-settings-ready")));
await expectEffort(page, "Quick");
await effortButton(page).click();
await expect(page.getByRole("option", { name: "Quick", exact: true })).toBeVisible();
await expect(page.getByRole("option", { name: "Thorough", exact: true })).toBeVisible();
await expect(page.getByRole("option", { name: "Gentle", exact: true })).toHaveCount(0);
await modelButton(page).click();
const efforts = page.getByRole("radiogroup", { name: "Effort Level", exact: true });
await expect(efforts.getByRole("radio", { name: "Quick", exact: true })).toBeVisible();
await expect(efforts.getByRole("radio", { name: "Thorough", exact: true })).toBeVisible();
await expect(efforts.getByRole("radio", { name: "Gentle", exact: true })).toHaveCount(0);
await page.keyboard.press("Escape");
await expect(box(page)).toHaveText("Keep this first task unsent");
await expectNoSubmission(page);
expect(await ipcCalls(page, "agent_set_config")).toEqual([]);
+7 -3
Переглянути файл
@@ -239,7 +239,7 @@
}
.quickLabel {
flex: none;
width: 52px;
width: 72px;
color: var(--fg-muted);
font-size: var(--fs-small);
}
@@ -401,10 +401,14 @@
text-overflow: ellipsis;
white-space: nowrap;
}
/* The effort is in the model popup: the button keeps the model's name readable. */
.chipDetail {
/* Details give way to the names, except the model's effort and context: the model's
name truncates first, since they are only shown here. */
.chipDetail:not(.modelDetail) {
display: none;
}
.modelDetail {
flex: none;
}
.inlineSetting {
display: none;
}
+63 -9
Переглянути файл
@@ -267,7 +267,7 @@ it("edits secondary settings from the compact popup and restores focus when dism
expect(trigger).toHaveFocus();
});
describe("model and effort button", () => {
describe("model settings", () => {
const copilotConfig = (effortLevels: string[] | null = ["low", "medium", "high", "xhigh"]): AgentConfigOption[] => [
{
id: "model",
@@ -314,18 +314,66 @@ describe("model and effort button", () => {
},
];
it("shows the effort as its own picker beside the model, and the mode with Allow All", () => {
it("keeps effort as a standalone setting when no model is available", () => {
render(
<ConfigPickers
config={[
{
id: "reasoning_effort",
name: "Reasoning Effort",
category: "thought_level",
description: null,
current: "medium",
via: "option",
values: [value("low"), value("medium")],
},
]}
onChange={vi.fn()}
/>,
);
expect(screen.getByRole("button", { name: "Reasoning Effort" })).toHaveTextContent("medium");
expect(screen.queryByRole("button", { name: "Agent settings" })).not.toBeInTheDocument();
});
it("keeps effort with model settings and the mode with Allow All", () => {
const onChange = vi.fn();
render(<ConfigPickers config={copilotConfig()} onChange={onChange} />);
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("Claude Sonnet 5.5");
const model = screen.getByRole("button", { name: "Model" });
expect(model).toHaveTextContent("Claude Sonnet 5.5");
expect(model).toHaveTextContent("medium");
expect(screen.getByRole("button", { name: "Mode" })).toHaveTextContent("AgentAllow All");
const effort = screen.getByRole("button", { name: "Reasoning Effort" });
expect(effort).toHaveTextContent("medium");
fireEvent.click(effort);
fireEvent.click(screen.getByRole("option", { name: "XHigh" }));
fireEvent.click(model);
const dialog = screen.getByRole("dialog", { name: "Model" });
const effort = within(dialog).getByRole("radiogroup", { name: "Effort Level" });
expect(within(effort).getByRole("radio", { name: "medium" })).toHaveAttribute("aria-checked", "true");
fireEvent.click(within(effort).getByRole("radio", { name: "XHigh" }));
expect(onChange).toHaveBeenCalledExactlyOnceWith("reasoning_effort", "xhigh");
});
it("offers more effort levels than fit the segmented control as a dropdown", () => {
const onChange = vi.fn();
const config = copilotConfig().map((o) =>
o.category === "thought_level"
? {
...o,
values: ["Low", "Medium", "High", "Extra high", "Max", "Ultra"].map((name) =>
value(name.toLowerCase().replace(" ", "-"), name),
),
current: "max",
}
: o,
);
render(<ConfigPickers config={config} onChange={onChange} />);
const model = screen.getByRole("button", { name: "Model" });
expect(model).toHaveTextContent("Max");
fireEvent.click(model);
const dialog = screen.getByRole("dialog", { name: "Model" });
expect(within(dialog).queryByRole("radiogroup", { name: "Effort Level" })).not.toBeInTheDocument();
fireEvent.click(within(dialog).getByRole("button", { name: /Reasoning Effort/ }));
fireEvent.click(screen.getByRole("option", { name: /Extra high/ }));
expect(onChange).toHaveBeenCalledWith("reasoning_effort", "extra-high");
});
it("tucks Fast into the model popup", () => {
const config = [
...copilotConfig().filter((o) => o.category !== "thought_level"),
@@ -369,13 +417,19 @@ describe("model and effort button", () => {
values: [value("default", "200K"), value("long_context", "1M")],
});
render(<ConfigPickers config={cfg} onChange={onChange} />);
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("Claude Sonnet 5.51M");
const model = screen.getByRole("button", { name: "Model" });
expect(model).toHaveTextContent("Claude Sonnet 5.5");
expect(model).toHaveTextContent("medium");
expect(model).toHaveTextContent("1M");
expect(model).toHaveAttribute("title", expect.stringContaining("Effort Level: medium · Context Size: 1M"));
fireEvent.click(screen.getByRole("button", { name: "Model" }));
fireEvent.click(model);
const dialog = screen.getByRole("dialog", { name: "Model" });
expect(within(dialog).queryByText("Balanced")).not.toBeInTheDocument();
expect(within(dialog).getByText("Medium cost")).toBeVisible();
const effortGroup = within(dialog).getByRole("radiogroup", { name: "Effort Level" });
expect(within(effortGroup).getByRole("radio", { name: "medium" })).toHaveAttribute("aria-checked", "true");
const contextGroup = within(dialog).getByRole("radiogroup", { name: "Context Size" });
expect(within(contextGroup).getByRole("radio", { name: "1M" })).toHaveAttribute("aria-checked", "true");
fireEvent.click(within(contextGroup).getByRole("radio", { name: "200K" }));
+48 -10
Переглянути файл
@@ -1,7 +1,7 @@
/**
* Model, effort, mode and approvals controls for a composer's bottom row. The model button
* opens a searchable model list (pinned models first, context size above it); the effort is
* its own picker beside it, one click away.
* opens a searchable model list (pinned models first) and keeps effort and context settings
* together above it.
*/
import { useEffect, useRef, useState, type KeyboardEvent } from "react";
import clsx from "clsx";
@@ -119,16 +119,16 @@ export function ConfigPickers({
const effort = config.find((o) => o.category === "thought_level" && o.values.length > 0);
const modelConfigs = modelConfigOptions(config);
const hasCostMeta = model?.values.some((v) => !!v.costCategory || !!v.usageMultiplier || !!v.pricing) ?? false;
const combinedModel = model && (modelRefresh || modelConfigs.length > 0 || hasCostMeta);
const combinedModel = !!model && (!!modelRefresh || modelConfigs.length > 0 || hasCostMeta || !!effort);
const tuckedEffort = combinedModel ? (effort ?? null) : null;
const tuckedModelConfig = new Set(modelConfigs.map((o) => o.id));
const mode = options.find((o) => o.category === "mode");
const allowAll = mode && options.find((o) => switchValues(o));
// Effort sits right after the model, as its own one-click picker.
const inline = options.filter(
(o) => o !== effort && o !== allowAll && !(combinedModel && tuckedModelConfig.has(o.id)),
);
if (effort) inline.splice(model ? inline.indexOf(model) + 1 : 0, 0, effort);
// The compact menu holds everything but the model and effort buttons (and the model's own parameters).
if (effort && !tuckedEffort) inline.splice(model ? inline.indexOf(model) + 1 : 0, 0, effort);
// The compact menu holds everything but the model, effort, and model-specific parameters.
const secondary = options.filter(
(o) => o.category !== "model" && o !== effort && !(combinedModel && tuckedModelConfig.has(o.id)),
);
@@ -146,6 +146,8 @@ export function ConfigPickers({
model={o}
modelValue={valueOf(o)}
modelConfigs={modelConfigs}
effort={tuckedEffort}
effortValue={tuckedEffort ? valueOf(tuckedEffort) : null}
valueOf={valueOf}
onChange={onChange}
modelRefresh={modelRefresh}
@@ -254,11 +256,16 @@ function ConfigPicker({
);
}
/** The model button: a searchable model list, with context size and the model's own settings above it. */
/** Effort levels that fit the popup's segmented control; more (Codex has six) get a dropdown. */
const SEGMENTED_EFFORT_MAX = 4;
/** The model button: a searchable model list, with effort, context size and model settings above it. */
function ModelPicker({
model,
modelValue,
modelConfigs,
effort,
effortValue,
valueOf,
onChange,
modelRefresh,
@@ -266,6 +273,8 @@ function ModelPicker({
model: AgentConfigOption;
modelValue: string | null;
modelConfigs: AgentConfigOption[];
effort: AgentConfigOption | null;
effortValue: string | null;
valueOf: (o: AgentConfigOption) => string | null;
onChange: (option: string, value: string) => void;
modelRefresh?: ModelRefresh;
@@ -282,9 +291,13 @@ function ModelPicker({
const contextOption = modelConfigs.find((o) => isContextOption(o.id) && o.values.length > 0);
const contextValue = contextOption ? valueOf(contextOption) : null;
const contextLabel = contextOption ? (selected(contextOption, contextValue)?.name ?? null) : null;
const contextLabel = contextOption
? ((selected(contextOption, contextValue) ?? contextOption.values[0])?.name ?? null)
: null;
const effortLabel = effort ? ((selected(effort, effortValue) ?? effort.values[0])?.name ?? null) : null;
const otherModelConfigs = modelConfigs.filter((o) => o !== contextOption);
const summary = [
effortLabel ? `${tx("Effort Level")}: ${effortLabel}` : null,
contextLabel ? `${tx("Context Size")}: ${contextLabel}` : null,
...otherModelConfigs.map((o) => {
const current = selected(o, valueOf(o));
@@ -310,7 +323,11 @@ function ModelPicker({
}}
>
<span className={styles.chipValue}>{modelName}</span>
{contextLabel && <span className={styles.chipDetail}>{contextLabel}</span>}
{(effortLabel || contextLabel) && (
<span className={clsx(styles.chipDetail, styles.modelDetail)}>
{[effortLabel, contextLabel].filter(Boolean).join(" · ")}
</span>
)}
<Icon name="chevron-down" size={14} className={styles.chipChevron} />
</button>
<Popup
@@ -325,8 +342,29 @@ function ModelPicker({
<T>Choose another model before starting.</T>
</p>
)}
{(contextOption || otherModelConfigs.length > 0) && (
{(effort || contextOption || otherModelConfigs.length > 0) && (
<div className={styles.quickSettings}>
{effort && (
<div className={styles.quickRow}>
<span className={styles.quickLabel}>
<T>Effort Level</T>
</span>
{effort.values.length <= SEGMENTED_EFFORT_MAX ? (
<SegmentedControl
ariaLabel={tx("Effort Level")}
options={effort.values.map((v) => ({
value: v.value,
label: v.name,
description: v.description ?? undefined,
}))}
value={effortValue ?? effort.values[0]!.value}
onChange={(v) => onChange(effort.id, v)}
/>
) : (
<ConfigPicker option={effort} value={effortValue} onChange={onChange} framed />
)}
</div>
)}
{contextOption && (
<div className={styles.quickRow}>
<span className={styles.quickLabel}>
+24 -16
Переглянути файл
@@ -1,5 +1,5 @@
import { beforeEach, expect, it, vi } from "vitest";
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
import { fireEvent, render, screen, waitFor, within } from "@testing-library/react";
import type { AgentConfigOption, AgentProvider, NewAgentTask } from "@/bindings";
import { useProject } from "@/platform/project";
import { HomeEditor } from "./HomeEditor";
@@ -77,26 +77,32 @@ beforeEach(() => {
updateComposer(HOME, { text: "Check the project" });
});
const effortButton = () => screen.getByRole("button", { name: "Reasoning" });
const modelButton = () => screen.getByRole("button", { name: "Model" });
async function chooseModel(model: string) {
fireEvent.click(screen.getByRole("button", { name: "Model" }));
if (!screen.queryByRole("dialog", { name: "Model" })) fireEvent.click(modelButton());
fireEvent.click(screen.getByRole("option", { name: model }));
fireEvent.pointerDown(document.body);
}
async function chooseEffort(effort: string) {
if (!screen.queryByRole("dialog", { name: "Model" })) fireEvent.click(modelButton());
const group = screen.getByRole("radiogroup", { name: "Effort Level" });
fireEvent.click(within(group).getByRole("radio", { name: effort }));
fireEvent.keyDown(document, { key: "Escape" });
}
it("switches model-specific levels and restores each draft effort before starting", async () => {
render(<HomeEditor />);
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("big");
expect(effortButton()).toHaveTextContent("high");
expect(modelButton()).toHaveTextContent("big");
expect(modelButton()).toHaveTextContent("high");
await chooseModel("small");
expect(effortButton()).toHaveTextContent("minimal");
fireEvent.click(effortButton());
fireEvent.click(screen.getByRole("option", { name: "medium" }));
expect(modelButton()).toHaveTextContent("minimal");
await chooseEffort("medium");
await chooseModel("big");
expect(effortButton()).toHaveTextContent("high");
expect(modelButton()).toHaveTextContent("high");
await chooseModel("small");
expect(effortButton()).toHaveTextContent("medium");
expect(modelButton()).toHaveTextContent("medium");
fireEvent.click(screen.getByRole("button", { name: "Start" }));
await waitFor(() => expect(backend.create).toHaveBeenCalled());
expect(backend.create.mock.calls[0]![0].config).toEqual([
@@ -124,11 +130,13 @@ it("uses GitHub Copilot's own defaults and preserves per-model context tier and
};
useAgents.setState({ providers: [copilot], draft: savedDraft({ provider: "copilot", config: {} }) });
render(<HomeEditor />);
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("gemini-4-carbondefault");
expect(effortButton()).toHaveTextContent("medium");
expect(modelButton()).toHaveTextContent("gemini-4-carbon");
expect(modelButton()).toHaveTextContent("medium");
expect(modelButton()).toHaveTextContent("default");
await chooseModel("gpt-5.6-sol");
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("gpt-5.6-soldefault");
expect(effortButton()).toHaveTextContent("medium");
expect(modelButton()).toHaveTextContent("gpt-5.6-sol");
expect(modelButton()).toHaveTextContent("medium");
expect(modelButton()).toHaveTextContent("default");
fireEvent.click(screen.getByRole("button", { name: "Start" }));
await waitFor(() => expect(backend.create).toHaveBeenCalled());
expect(backend.create.mock.calls[0]![0].config).toEqual([
@@ -141,7 +149,7 @@ it("uses GitHub Copilot's own defaults and preserves per-model context tier and
it.each(["plain", "unknown"])("hides effort for %s models and sends no stale effort", async (model) => {
render(<HomeEditor />);
await chooseModel(model);
expect(screen.getByRole("button", { name: "Model" })).toHaveAttribute("aria-haspopup", "dialog");
expect(modelButton()).toHaveAttribute("aria-haspopup", "dialog");
fireEvent.click(screen.getByRole("button", { name: "Start" }));
await waitFor(() => expect(backend.create).toHaveBeenCalled());
expect(backend.create.mock.calls[0]![0].config).toEqual([{ id: "model", value: model }]);
@@ -162,7 +170,7 @@ it("ignores old provider-wide effort choices and refreshes unsupported per-model
draft: savedDraft({ provider: "fake", config: { effort: "low" }, thoughtLevels: { big: { effort: "removed" } } }),
});
render(<HomeEditor />);
expect(effortButton()).toHaveTextContent("high");
expect(modelButton()).toHaveTextContent("high");
fireEvent.click(screen.getByRole("button", { name: "Start" }));
await waitFor(() => expect(backend.create).toHaveBeenCalled());
expect(backend.create.mock.calls[0]![0].config).toContainEqual({ id: "effort", value: "high" });
+10 -11
Переглянути файл
@@ -219,7 +219,7 @@ it("refreshes an existing chat's searchable model choices and switches through i
expect(modelButton).toHaveTextContent("old");
expect(screen.getByRole("option", { name: "session-only" })).toBeVisible();
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("low");
expect(modelButton).toHaveTextContent("low");
expect(screen.getByRole("button", { name: "Mode" })).toHaveTextContent("plan");
expect(screen.getByText("Earlier message")).toBeVisible();
expect(screen.queryByText("catalog-only")).not.toBeInTheDocument();
@@ -324,7 +324,7 @@ it("retains cached model and effort choices after a command failure and retries
draft: savedDraft({ provider: "first", config: { model: "big" }, thoughtLevels: { big: { effort: "low" } } }),
});
render(<HomeEditor />);
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("low");
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("low");
fireEvent.click(screen.getByRole("button", { name: "Model" }));
expect(await screen.findByRole("alert")).toHaveTextContent("connection lost");
fireEvent.click(screen.getByRole("option", { name: "small" }));
@@ -351,7 +351,7 @@ it("preserves a valid remembered model and effort when discovery changes the def
render(<HomeEditor />);
await waitFor(() => expect(useAgents.getState().modelRequests.size).toBe(0));
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("big");
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("low");
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("low");
fireEvent.click(screen.getByRole("button", { name: "Model" }));
expect(screen.getByRole("option", { name: "new" })).toBeVisible();
fireEvent.keyDown(document, { key: "Escape" });
@@ -471,7 +471,7 @@ it("discovers an uncached model's own settings before its first task and restore
fireEvent.click(screen.getByRole("option", { name: "small" }));
await waitFor(() => expect(backend.refresh).toHaveBeenLastCalledWith("first", false, "small"));
expect(screen.getByText("Loading model settings…")).toHaveAttribute("role", "status");
expect(screen.queryByRole("button", { name: "Reasoning" })).not.toBeInTheDocument();
expect(screen.queryByRole("dialog", { name: "Model" })).not.toBeInTheDocument();
expect(backend.create).not.toHaveBeenCalled();
await act(async () =>
pending.resolve(
@@ -489,17 +489,16 @@ it("discovers an uncached model's own settings before its first task and restore
),
);
expect(screen.queryByText("Loading model settings…")).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("medium");
fireEvent.click(screen.getByRole("button", { name: "Reasoning" }));
fireEvent.click(screen.getByRole("option", { name: "max" }));
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("medium");
fireEvent.click(screen.getByRole("button", { name: "Model" }));
fireEvent.click(screen.getByRole("radio", { name: "max" }));
expect(screen.getByRole("radio", { name: "long_context" })).toBeVisible();
fireEvent.click(screen.getByRole("radio", { name: "long_context" }));
fireEvent.click(screen.getByRole("option", { name: "big" }));
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("high");
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("high");
fireEvent.click(screen.getByRole("button", { name: "Model" }));
fireEvent.click(screen.getByRole("option", { name: "small" }));
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("max");
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("max");
expect(backend.refresh).toHaveBeenCalledTimes(2);
fireEvent.click(screen.getByRole("button", { name: "Start" }));
await waitFor(() => expect(backend.create).toHaveBeenCalled());
@@ -549,7 +548,7 @@ it("waits for an unrelated lookup and discovers only the latest selected model",
ok(catalog("first", { thoughtLevels: { latest: [option("effort", "thought_level", ["medium", "max"])] } })),
),
);
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("medium");
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("medium");
expect(backend.refresh).toHaveBeenCalledTimes(2);
expect(backend.create).not.toHaveBeenCalled();
});
@@ -607,7 +606,7 @@ it("does not leak a delayed model's levels or failure into a newer selection", a
),
);
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("big");
expect(screen.getByRole("button", { name: "Reasoning" })).toHaveTextContent("low");
expect(screen.getByRole("button", { name: "Model" })).toHaveTextContent("low");
fireEvent.click(screen.getByRole("button", { name: "Model" }));
expect(screen.queryByRole("alert")).not.toBeInTheDocument();
expect(screen.getByRole("button", { name: "Refresh models" })).toBeEnabled();
+6 -10
Переглянути файл
@@ -36,20 +36,16 @@ describe("ideavimrc parsing", () => {
);
});
it("parses the clipboard list option, including the += append form", () => {
it("parses set with Vim's =, +=, -= and ^= forms", () => {
expect(parseVimrc("set clipboard=unnamedplus").commands).toEqual([
{ kind: "set", name: "clipboard", value: "unnamedplus" },
]);
expect(parseVimrc("set clipboard+=unnamed").commands).toEqual([
{ kind: "set", name: "clipboard", value: "unnamed", append: true },
]);
// Only list options append; other forms stay unsupported syntax.
expect(parseVimrc("set textwidth+=4").ignored.map((i) => i.reason)).toEqual([
"unsupported option syntax: textwidth+=4",
]);
expect(parseVimrc("set clipboard-=unnamed").ignored.map((i) => i.reason)).toEqual([
"unsupported option syntax: clipboard-=unnamed",
expect(parseVimrc("set clipboard+=unnamed cb^=unnamedplus tw-=10").commands).toEqual([
{ kind: "set", name: "clipboard", value: "unnamed", op: "+=" },
{ kind: "set", name: "cb", value: "unnamedplus", op: "^=" },
{ kind: "set", name: "tw", value: "10", op: "-=" },
]);
expect(parseVimrc("set ideajoin+=x").ignored.map((i) => i.reason)).toEqual(["option not supported: ideajoin"]);
});
it("parses map variants with modes, noremap and the leader in effect at that line", () => {
+19 -2
Переглянути файл
@@ -156,11 +156,28 @@ describe("Vim engine", () => {
view.destroy();
});
it("appends list option values from the rc file", () => {
it("applies +=, -= and ^= to list and number options from the rc file", () => {
try {
const problems = applyRcCommands(parseVimrc("set clipboard+=unnamed\nset clipboard+=unnamedplus").commands);
const problems = applyRcCommands(
parseVimrc("set clipboard+=unnamed\nset cb+=unnamedplus\nset clipboard+=unnamed").commands,
);
expect(problems).toEqual([]);
expect(Vim.getOption("clipboard")).toBe("ideaput,autoselect,unnamed,unnamedplus");
applyRcCommands(parseVimrc("set clipboard-=autoselect\nset clipboard^=unnamedplus").commands);
expect(Vim.getOption("clipboard")).toBe("ideaput,unnamed,unnamedplus");
applyRcCommands(parseVimrc("set clipboard^=autoselect").commands);
expect(Vim.getOption("clipboard")).toBe("autoselect,ideaput,unnamed,unnamedplus");
const timeout = Vim.getOption("insertModeEscKeysTimeout");
applyRcCommands(
parseVimrc(
"set insertModeEscKeysTimeout=100\nset insertModeEscKeysTimeout+=50\nset insertModeEscKeysTimeout^=2\nset insertModeEscKeysTimeout-=60",
).commands,
);
expect(Vim.getOption("insertModeEscKeysTimeout")).toBe(240);
expect(applyRcCommands(parseVimrc("set insertModeEscKeysTimeout+=x").commands)).toEqual([
"insertModeEscKeysTimeout: number required: x",
]);
Vim.setOption("insertModeEscKeysTimeout", timeout);
} finally {
Vim.setOption("clipboard", "ideaput,autoselect");
}
+1 -1
Переглянути файл
@@ -16,7 +16,7 @@ const CLIPBOARD_DEFAULT = "ideaput,autoselect";
const MIRROR_OPTIONS = new Set(["unnamed", "unnamedplus"]);
// The rc file's `set clipboard=…` lines need the option to exist before they are applied.
Vim.defineOption("clipboard", CLIPBOARD_DEFAULT, "string");
Vim.defineOption("clipboard", CLIPBOARD_DEFAULT, "string", ["cb"]);
/** Whether the user asked for unnamed register writes to reach the system clipboard. */
function unnamedMirrors(): boolean {
+17 -5
Переглянути файл
@@ -14,7 +14,7 @@ import { showStatusInfo } from "@/workbench/contributions";
import { installClipboardHooks } from "./clipboard";
import { modeAction, modeMovedToIde, movedToIde, VIM_EDITOR_ATTR, VIM_MODE_ATTR, vimModeOf } from "./conflicts";
import { useVimMode, type VimModeState } from "./mode";
import { resolveActionId, type RcCommand } from "./rc";
import { resolveActionId, type RcCommand, type SetOp } from "./rc";
import { useVimSettings } from "./settings";
import { mapFunctionTextObjects } from "./textObjects";
@@ -497,14 +497,26 @@ function firstKey(lhs: string): string {
return /^<[^<>]+>|^./.exec(lhs)?.[0] ?? lhs;
}
/** `set clipboard+=unnamed`: the comma list option with `add` appended once. */
function appendedOption(name: string, add: string): string {
/**
* The value `set name{op}value` gives an option, as in Vim: numbers add, subtract or multiply;
* comma lists append an item once (`+=`), remove it (`-=`) or put it first (`^=`).
*/
function adjustedOption(name: string, op: SetOp, value: string): string | number {
const current = Vim.getOption(name);
// A number option (rc values arrive as text, so `set x=100` stores "100").
if (typeof current === "number" || (typeof current === "string" && /^-?\d+$/.test(current))) {
if (!/^-?\d+$/.test(value)) throw new Error(`number required: ${value}`);
const [a, b] = [Number(current), Number(value)];
return op === "+=" ? a + b : op === "-=" ? a - b : a * b;
}
const items = (typeof current === "string" ? current : "")
.split(",")
.map((v) => v.trim())
.filter(Boolean);
return items.includes(add) ? items.join(",") : [...items, add].join(",");
const rest = items.filter((v) => v !== value);
if (op === "-=") return rest.join(",");
if (op === "^=") return (items.includes(value) ? items : [value, ...items]).join(",");
return (items.includes(value) ? items : [...items, value]).join(",");
}
/** Applies rc commands (replacing earlier rc mappings). Returns problems to report. */
@@ -518,7 +530,7 @@ export function applyRcCommands(commands: readonly RcCommand[]): string[] {
for (const c of commands) {
try {
if (c.kind === "set") {
const err = Vim.setOption(c.name, c.append ? appendedOption(c.name, String(c.value)) : c.value);
const err = Vim.setOption(c.name, c.op ? adjustedOption(c.name, c.op, String(c.value)) : c.value);
if (err) problems.push(`set ${c.name}: ${err.message}`);
} else if (c.kind === "map") {
if (c.noremap) Vim.noremap(c.lhs, c.rhs, c.mode as string);
+6 -7
Переглянути файл
@@ -12,12 +12,14 @@ import { IDEA_ACTIONS } from "@/platform/ideaActions";
export type MapMode = "normal" | "insert" | "visual" | "operatorPending" | undefined;
export type RcCommand =
/** `append` marks `set name+=value`, the way a comma list option gains an item. */
| { kind: "set"; name: string; value: string | boolean; append?: boolean }
/** `op` is Vim's `+=` (append to a list, add to a number), `-=` (remove, subtract) or `^=` (prepend, multiply). */
| { kind: "set"; name: string; value: string | boolean; op?: SetOp }
| { kind: "map"; mode: MapMode; noremap: boolean; lhs: string; rhs: string }
/** A key mapped to one Ex command, e.g. `<Action>(ReformatCode)` → `action ReformatCode`. */
| { kind: "mapEx"; mode: MapMode; lhs: string; ex: string };
export type SetOp = "+=" | "-=" | "^=";
export interface RcIgnored {
/** The sourced file it came from, as written after `source`; absent for the rc file itself. */
file?: string;
@@ -113,9 +115,8 @@ const SUPPORTED_OPTIONS = new Set([
"langmap",
"lmap",
"clipboard",
"cb",
]);
/** Comma list options, the ones Vim's `+=` appends an item to (`set clipboard+=unnamed`). */
const LIST_OPTIONS = new Set(["clipboard"]);
const MAP_FLAGS = /^<(silent|unique|nowait|buffer|expr|script)>$/i;
function leaderKeys(value: string): string {
@@ -196,11 +197,9 @@ export function parseVimrc(text: string, sources?: ReadonlyMap<string, string |
if (!restWords.length) return ignore("set without options");
for (const opt of restWords) {
const eq = /^([a-zA-Z]+)([-+^]?)=(.*)$/.exec(opt);
// Vim only appends to comma list options; `-=` / `^=` are not implemented.
const append = eq?.[2] === "+" && LIST_OPTIONS.has(eq[1]!);
let cmd: RcCommand | null = null;
if (eq) {
if (!eq[2] || append) cmd = { kind: "set", name: eq[1]!, value: eq[3]!, ...(append ? { append: true } : {}) };
cmd = { kind: "set", name: eq[1]!, value: eq[3]!, ...(eq[2] ? { op: `${eq[2]}=` as SetOp } : {}) };
} else if (/^[a-zA-Z]+$/.test(opt)) {
const negated = !SUPPORTED_OPTIONS.has(opt) && opt.startsWith("no") && SUPPORTED_OPTIONS.has(opt.slice(2));
cmd = { kind: "set", name: negated ? opt.slice(2) : opt, value: !negated };