mirror of
https://github.com/helix-editor/helix.git
synced 2024-12-18 14:01:55 +04:00
registers: Use saved values for clipboard providers which can't read
This fixes reading from the clipboard when using the termcode provider. Reading isn't implemented for the termcode provider so `get_contents` returns `ClipboardError::ReadingNotSupported`. `read_from_clipboard` needs to recognize this case and use the saved values instead of emitting an error log and returning nothing. Follow-up of #10839 Also see #12142
This commit is contained in:
parent
548f04fe26
commit
ec1628c07f
@ -5,7 +5,7 @@
|
||||
use helix_core::NATIVE_LINE_ENDING;
|
||||
|
||||
use crate::{
|
||||
clipboard::{ClipboardProvider, ClipboardType},
|
||||
clipboard::{ClipboardError, ClipboardProvider, ClipboardType},
|
||||
Editor,
|
||||
};
|
||||
|
||||
@ -238,6 +238,10 @@ fn read_from_clipboard<'a>(
|
||||
RegisterValues::new(iter::once(contents.into()))
|
||||
}
|
||||
}
|
||||
Err(ClipboardError::ReadingNotSupported) => match saved_values {
|
||||
Some(values) => RegisterValues::new(values.iter().map(Cow::from).rev()),
|
||||
None => RegisterValues::new(iter::empty()),
|
||||
},
|
||||
Err(err) => {
|
||||
log::error!(
|
||||
"Failed to read {} clipboard: {err}",
|
||||
|
Loading…
Reference in New Issue
Block a user