8000 Fix: Copying doesn't work via CLI nor TUI by jooaf · Pull Request #9 · jooaf/thoth · GitHub
[go: up one dir, main page]

Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ You can install [from the AUR](https://aur.archlinux.org/packages/thoth) using a
```bash
paru -S thoth
```
Or
```bash
yay -S thoth
```

### Debian/Ubuntu
You can install the `.deb` for your platform by doing the following (note: the URL is an example. To get the latest release please look at the [Releases](https://github.com/jooaf/thoth/releases) section)
Expand Down
3 changes: 2 additions & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,9 @@ pub fn copy_block(name: &str) -> Result<()> {
let mut ctx = result_ctx.unwrap();

let is_success = ctx.set_contents(block_content.join("\n"));
let get_content_success = ctx.get_contents();

if is_success.is_err() {
if is_success.is_err() || get_content_success.is_err() {
bail!(format!(
"Failed to copy contents of block {} to system clipboard",
block_name
Expand Down
6 changes: 6 additions & 0 deletions src/scrollable_textarea.rs
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,8 @@ impl ScrollableTextArea {
.map_err(|e| anyhow::anyhow!("Failed to create clipboard context: {}", e))?;
ctx.set_contents(content)
.map_err(|e| anyhow::anyhow!("Failed to set clipboard contents: {}", e))?;
ctx.get_contents()
.map_err(|e| anyhow::anyhow!("Failed to set clipboard contents: {}", e))?;
}
Ok(())
}
Expand Down Expand Up @@ -218,6 +220,8 @@ impl ScrollableTextArea {
let content = textarea.lines().join("\n");
let mut ctx = ClipboardContext::new().unwrap();
ctx.set_contents(content).unwrap();
ctx.get_contents()
.map_err(|e| anyhow::anyhow!("Failed to set clipboard contents: {}", e))?;
}
Ok(())
}
Expand All @@ -233,6 +237,8 @@ impl ScrollableTextArea {
let content = all_lines[min_row..max_row].join("\n");
let mut ctx = ClipboardContext::new().unwrap();
ctx.set_contents(content).unwrap();
ctx.get_contents()
.map_err(|e| anyhow::anyhow!("Failed to set clipboard contents: {}", e))?;
}
}
// reset selection
Expand Down
0