Use get_register_selections
This commit is contained in:
parent
eda1d2bb96
commit
d1957a47c1
@ -22,6 +22,23 @@ pub fn get_selections(keys: Option<&'_ str>) -> Result<Vec<Selection>, KakError>
|
|||||||
response("%val{selections}", keys)
|
response("%val{selections}", keys)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_register_selections<R>(r: R) -> Result<Vec<Selection>, KakError>
|
||||||
|
where
|
||||||
|
R: AsRef<Register>,
|
||||||
|
{
|
||||||
|
cmd(&format!(
|
||||||
|
r#"
|
||||||
|
evaluate-commands -draft %{{
|
||||||
|
execute-keys '\"{}z';
|
||||||
|
echo -quoting shell -to-file {} -- %val{{selections}};
|
||||||
|
}}"#,
|
||||||
|
r.as_ref().kak_escaped(),
|
||||||
|
get_var("kak_response_fifo")?
|
||||||
|
))?;
|
||||||
|
let selections = shell_words::split(&fs::read_to_string(&get_var("kak_response_fifo")?)?)?;
|
||||||
|
Ok(selections)
|
||||||
|
}
|
||||||
|
|
||||||
/// # Errors
|
/// # Errors
|
||||||
///
|
///
|
||||||
/// Will return `Err` if command fifo could not be opened, read from, or written to
|
/// Will return `Err` if command fifo could not be opened, read from, or written to
|
||||||
|
11
src/set.rs
11
src/set.rs
@ -1,6 +1,7 @@
|
|||||||
// use crate::utils;
|
// use crate::utils;
|
||||||
use kakplugin::{
|
use kakplugin::{
|
||||||
get_selections, get_selections_with_desc, reg, set_selections_desc, types::Register, KakError,
|
get_register_selections, get_selections, get_selections_with_desc, set_selections_desc,
|
||||||
|
types::Register, KakError,
|
||||||
};
|
};
|
||||||
use linked_hash_map::LinkedHashMap;
|
use linked_hash_map::LinkedHashMap;
|
||||||
use linked_hash_set::LinkedHashSet;
|
use linked_hash_set::LinkedHashSet;
|
||||||
@ -75,19 +76,19 @@ pub fn set<'sel>(options: &'_ Options) -> Result<String, KakError> {
|
|||||||
let (left_selections, right_selections) = match (&left_register, &right_register) {
|
let (left_selections, right_selections) = match (&left_register, &right_register) {
|
||||||
(Register::Underscore, r) => {
|
(Register::Underscore, r) => {
|
||||||
let l_selections = get_selections(None)?;
|
let l_selections = get_selections(None)?;
|
||||||
let r_selections = reg(*r, None)?;
|
let r_selections = get_register_selections(r)?;
|
||||||
|
|
||||||
(l_selections, r_selections)
|
(l_selections, r_selections)
|
||||||
}
|
}
|
||||||
(l, Register::Underscore) => {
|
(l, Register::Underscore) => {
|
||||||
let r_selections = get_selections(None)?;
|
let r_selections = get_selections(None)?;
|
||||||
let l_selections = reg(*l, None)?;
|
let l_selections = get_register_selections(l)?;
|
||||||
|
|
||||||
(l_selections, r_selections)
|
(l_selections, r_selections)
|
||||||
}
|
}
|
||||||
(l, r) => {
|
(l, r) => {
|
||||||
let l_selections = reg(*l, None)?;
|
let l_selections = get_register_selections(l)?;
|
||||||
let r_selections = reg(*r, None)?;
|
let r_selections = get_register_selections(r)?;
|
||||||
|
|
||||||
(l_selections, r_selections)
|
(l_selections, r_selections)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user