From 3a681458485f5f0fe30496a3dab09aba0cb6ae0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicol=C3=A1s=20Hatcher?= Date: Fri, 4 Jul 2025 23:15:18 +0200 Subject: [PATCH] FIX: Copied csv had an extra line Fixes #393 --- base/src/test/user_model/test_paste_csv.rs | 2 +- base/src/user_model/common.rs | 2 +- webapp/IronCalc/src/components/Workbook/Workbook.tsx | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/base/src/test/user_model/test_paste_csv.rs b/base/src/test/user_model/test_paste_csv.rs index 3331ec7..4b2ff7e 100644 --- a/base/src/test/user_model/test_paste_csv.rs +++ b/base/src/test/user_model/test_paste_csv.rs @@ -167,7 +167,7 @@ fn copy_paste_internal() { let copy = model.copy_to_clipboard().unwrap(); assert_eq!( copy.csv, - "42\t127\n\"A season of faith\t \"\"perfection\"\"\"\t\n" + "42\t127\n\"A season of faith\t \"\"perfection\"\"\"" ); assert_eq!(copy.range, (1, 1, 2, 2)); diff --git a/base/src/user_model/common.rs b/base/src/user_model/common.rs index a7a5b34..ecc9d41 100644 --- a/base/src/user_model/common.rs +++ b/base/src/user_model/common.rs @@ -1641,7 +1641,7 @@ impl UserModel { .map_err(|e| format!("Error converting from utf8: '{e}'"))?; Ok(Clipboard { - csv, + csv: csv.trim().to_string(), data, sheet, range: (row_start, column_start, row_end, column_end), diff --git a/webapp/IronCalc/src/components/Workbook/Workbook.tsx b/webapp/IronCalc/src/components/Workbook/Workbook.tsx index bdd2bed..70db123 100644 --- a/webapp/IronCalc/src/components/Workbook/Workbook.tsx +++ b/webapp/IronCalc/src/components/Workbook/Workbook.tsx @@ -473,7 +473,7 @@ const Workbook = (props: { model: Model; workbookState: WorkbookState }) => { sheet, clipboardId, }); - event.clipboardData.setData("text/plain", data.csv); + event.clipboardData.setData("text/plain", data.csv.trim()); event.clipboardData.setData("application/json", clipboardJsonStr); event.preventDefault(); event.stopPropagation();