Skip to content

Commit

Permalink
fix: size restriction when uploading files and fix wrong new line whe…
Browse files Browse the repository at this point in the history
…n downloading files
  • Loading branch information
st-vi committed Jan 8, 2024
1 parent 758da8c commit 8019e59
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion WebSocketClient/src/ImportExportFiles.ts
Original file line number Diff line number Diff line change
@@ -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'});
Expand Down Expand Up @@ -36,7 +38,12 @@ export function uploadFile(): Promise<string> {
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);
}

});
};
})
Expand Down
2 changes: 1 addition & 1 deletion WebSocketClient/src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down

0 comments on commit 8019e59

Please sign in to comment.