mirror of
https://github.com/aljazceru/opencode.git
synced 2025-12-21 09:44:21 +01:00
tui: fix file path handling when pasting images with spaces in filename
- Fixes issue where files with spaces in their names couldn't be pasted as images - Prevents default paste behavior to avoid conflicts with image insertion - Improves error handling for file reading operations
This commit is contained in:
@@ -616,14 +616,16 @@ export function Prompt(props: PromptProps) {
|
|||||||
|
|
||||||
// trim ' from the beginning and end of the pasted content. just
|
// trim ' from the beginning and end of the pasted content. just
|
||||||
// ' and nothing else
|
// ' and nothing else
|
||||||
const filepath = pastedContent.replace(/^'+|'+$/g, "")
|
const filepath = pastedContent.replace(/^'+|'+$/g, "").replace(/\\ /g, " ")
|
||||||
|
console.log(pastedContent, filepath)
|
||||||
try {
|
try {
|
||||||
const file = Bun.file(filepath)
|
const file = Bun.file(filepath)
|
||||||
if (file.type.startsWith("image/")) {
|
if (file.type.startsWith("image/")) {
|
||||||
|
event.preventDefault()
|
||||||
const content = await file
|
const content = await file
|
||||||
.arrayBuffer()
|
.arrayBuffer()
|
||||||
.then((buffer) => Buffer.from(buffer).toString("base64"))
|
.then((buffer) => Buffer.from(buffer).toString("base64"))
|
||||||
.catch(() => {})
|
.catch(console.error)
|
||||||
if (content) {
|
if (content) {
|
||||||
await pasteImage({
|
await pasteImage({
|
||||||
filename: file.name,
|
filename: file.name,
|
||||||
|
|||||||
Reference in New Issue
Block a user