Skip to content

Commit

Permalink
registers: Use saved values for clipboard providers which can't read
Browse files Browse the repository at this point in the history
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
  • Loading branch information
the-mikedavis committed Dec 2, 2024
1 parent 548f04f commit ec1628c
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion helix-view/src/register.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ use arc_swap::access::DynAccess;
use helix_core::NATIVE_LINE_ENDING;

use crate::{
clipboard::{ClipboardProvider, ClipboardType},
clipboard::{ClipboardError, ClipboardProvider, ClipboardType},
Editor,
};

Expand Down Expand Up @@ -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}",
Expand Down

0 comments on commit ec1628c

Please sign in to comment.