From 8019e591f80a9fca14c9cc2453cbd705b951b0a4 Mon Sep 17 00:00:00 2001 From: Stefan Date: Mon, 8 Jan 2024 08:27:09 +0100 Subject: [PATCH] fix: size restriction when uploading files and fix wrong new line when downloading files --- WebSocketClient/src/ImportExportFiles.ts | 9 ++++++++- WebSocketClient/src/main.ts | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/WebSocketClient/src/ImportExportFiles.ts b/WebSocketClient/src/ImportExportFiles.ts index cefa126..2529a06 100644 --- a/WebSocketClient/src/ImportExportFiles.ts +++ b/WebSocketClient/src/ImportExportFiles.ts @@ -1,3 +1,5 @@ +import config from './config'; + export function downloadFile(content: string, filename: string): void { // Create a Blob from the file content const blob = new Blob([content], {type: 'text/plain'}); @@ -36,7 +38,12 @@ export function uploadFile(): Promise { uploadInput.files = null; uploadInput.value = ""; stringPromise.then((res) => { - resolve(res); + if(res.length > config.MAX_NUMBER_LINES){ + resolve(res.split('\n').slice(0, config.MAX_NUMBER_LINES - 1).reduce((acc, curr) => acc + curr + "\n", "")); + }else{ + resolve(res); + } + }); }; }) diff --git a/WebSocketClient/src/main.ts b/WebSocketClient/src/main.ts index 7a68b6b..960890c 100644 --- a/WebSocketClient/src/main.ts +++ b/WebSocketClient/src/main.ts @@ -145,7 +145,7 @@ const createLanguageClient = (transports: MessageTransports): MonacoLanguageClie vscode.commands.registerCommand("uvlPlayground/downloadFile", () => { const model1 = globalEditor?.getModel(); if(model1){ - downloadFile(model1.getLinesContent().reduce((prev, curr) => {return prev+'\n'+curr}, ""), fileID); + downloadFile(model1.getLinesContent().reduce((prev, curr) => {return prev+curr+'\n'}, ""), fileID); } }); const client = new MonacoLanguageClient({