mirror of
https://github.com/clash-verge-rev/clash-verge-rev.git
synced 2026-01-28 07:14:40 +08:00
fix(seq): prepend newly added proxies to first selector group
This commit is contained in:
@@ -29,6 +29,6 @@
|
||||
- 在 Linux NVIDIA 显卡环境下尝试禁用 WebKit DMABUF 渲染以规避潜在问题
|
||||
- Windows 下自启动改为计划任务实现
|
||||
- 改进托盘和窗口操作频率限制实现
|
||||
- 使用「编辑节点」添加节点时,自动将节点添加到第一个 `select` 类型的代理组末尾
|
||||
- 使用「编辑节点」添加节点时,自动将节点添加到第一个 `select` 类型的代理组的第一位
|
||||
|
||||
</details>
|
||||
|
||||
@@ -100,17 +100,24 @@ pub fn use_seq(seq: SeqMap, mut config: Mapping, field: &str) -> Mapping {
|
||||
});
|
||||
|
||||
if !appended_to_selector && !added_proxy_names.is_empty() && is_selector_group(group_map) {
|
||||
let mut seq = proxies_seq.unwrap_or_else(Sequence::new);
|
||||
let mut existing = seq
|
||||
.iter()
|
||||
.filter_map(Value::as_str)
|
||||
.map(str::to_owned)
|
||||
.collect::<HashSet<String>>();
|
||||
let base_seq = proxies_seq.unwrap_or_else(Sequence::new);
|
||||
let mut seq = Sequence::new();
|
||||
let mut existing = HashSet::new();
|
||||
for name in &added_proxy_names {
|
||||
if existing.insert(name.clone()) {
|
||||
seq.push(Value::String(name.clone()));
|
||||
}
|
||||
}
|
||||
for value in base_seq {
|
||||
match &value {
|
||||
Value::String(name) => {
|
||||
if existing.insert(name.to_owned()) {
|
||||
seq.push(value);
|
||||
}
|
||||
}
|
||||
_ => seq.push(value),
|
||||
}
|
||||
}
|
||||
proxies_seq = Some(seq);
|
||||
appended_to_selector = true;
|
||||
}
|
||||
@@ -270,7 +277,7 @@ proxy-groups:
|
||||
.as_sequence()
|
||||
.expect("group proxies should be a sequence");
|
||||
let names: Vec<&str> = group1_proxies.iter().filter_map(Value::as_str).collect();
|
||||
assert_eq!(names, vec!["proxy1", "proxy3", "proxy4"]);
|
||||
assert_eq!(names, vec!["proxy3", "proxy4", "proxy1"]);
|
||||
|
||||
let group2_proxies = groups[1]
|
||||
.as_mapping()
|
||||
|
||||
Reference in New Issue
Block a user