From e60a6de7d6ff1a0ef379579a934f5062090f2ef4 Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 3 Apr 2025 12:27:45 -0400 Subject: [PATCH 1/3] Fix issuse where Undo deletes the file --- src/commands/compile.ts | 15 ++++++++------- src/extension.ts | 13 +++++++++++-- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/src/commands/compile.ts b/src/commands/compile.ts index 34403492..cd4dae61 100644 --- a/src/commands/compile.ts +++ b/src/commands/compile.ts @@ -30,7 +30,6 @@ import { notNull, outputChannel, RateLimiter, - replaceFile, routineNameTypeRegex, } from "../utils"; import { StudioActions } from "./studio"; @@ -228,12 +227,14 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[] if (notIsfs(file.uri)) { const content = await api.getDoc(file.name).then((data) => data.result.content); exportedUris.add(file.uri.toString()); // Set optimistically - await replaceFile(file.uri, content).catch((e) => { - // Save failed, so remove this URI from the set - exportedUris.delete(file.uri.toString()); - // Re-throw the error - throw e; - }); + await vscode.workspace.fs + .writeFile(file.uri, Buffer.isBuffer(content) ? content : new TextEncoder().encode(content.join("\n"))) + .then(undefined, (e) => { + // Save failed, so remove this URI from the set + exportedUris.delete(file.uri.toString()); + // Re-throw the error + throw e; + }); if (isClassOrRtn(file.uri)) { // Update the document index updateIndexForDocument(file.uri, undefined, undefined, content); diff --git a/src/extension.ts b/src/extension.ts index b8f96c6b..83bd0fe9 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -104,7 +104,6 @@ import { isClassOrRtn, addWsServerRootFolderData, getWsFolder, - replaceFile, } from "./utils"; import { ObjectScriptDiagnosticProvider } from "./providers/ObjectScriptDiagnosticProvider"; import { DocumentLinkProvider } from "./providers/DocumentLinkProvider"; @@ -1272,7 +1271,17 @@ export async function activate(context: vscode.ExtensionContext): Promise { // Generate the new content const newContent = generateFileContent(uri, fileName, sourceContent); // Write the new content to the file - return replaceFile(uri, newContent.content); + const wsEdit = new vscode.WorkspaceEdit(); + wsEdit.replace( + uri, + new vscode.Range(0, 0, newContent.content.length + 1, 0), + newContent.content.join("\n"), + { + label: "ObjectScript autoAdjustName", + needsConfirmation: false, + } + ); + await vscode.workspace.applyEdit(wsEdit); }) ); }), From f0eb3af4a8b8d26b189c90083ca2b3dde694cbe6 Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 3 Apr 2025 12:35:43 -0400 Subject: [PATCH 2/3] CHANGELOG and README updates --- CHANGELOG.md | 4 ++++ README.md | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 59eec17a..3d8ce971 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +## [3.0.1] 04-Apr-2025 +- Fixes + - Fix issue where `Undo` after a save deletes the file being edited (#1524) + ## [3.0.0] 02-Apr-2025 - Enhancements - Client-side editing overhaul (#1401, #1470, #1515, #1520): diff --git a/README.md b/README.md index 318d07a4..51402e34 100644 --- a/README.md +++ b/README.md @@ -55,8 +55,8 @@ To unlock these features (optional): 1. Download and install a beta version from GitHub. This is necessary because Marketplace does not allow publication of extensions that use proposed APIs. - Go to https://github.com/intersystems-community/vscode-objectscript/releases - - Locate the beta immediately above the release you installed from Marketplace. For instance, if you installed `3.0.0`, look for `3.0.1-beta.1`. This will be functionally identical to the Marketplace version apart from being able to use proposed APIs. - - Download the VSIX file (for example `vscode-objectscript-3.0.1-beta.1.vsix`) and install it. One way to install a VSIX is to drag it from your download folder and drop it onto the list of extensions in the Extensions view of VS Code. + - Locate the beta immediately above the release you installed from Marketplace. For instance, if you installed `3.0.1`, look for `3.0.2-beta.1`. This will be functionally identical to the Marketplace version apart from being able to use proposed APIs. + - Download the VSIX file (for example `vscode-objectscript-3.0.2-beta.1.vsix`) and install it. One way to install a VSIX is to drag it from your download folder and drop it onto the list of extensions in the Extensions view of VS Code. 2. From [Command Palette](https://code.visualstudio.com/docs/getstarted/tips-and-tricks#_command-palette) choose `Preferences: Configure Runtime Arguments`. 3. In the argv.json file that opens, add this line (required for both Stable and Insiders versions of VS Code): From 94d4a5da01c73704dead52e6c3a22de67ef3f9ee Mon Sep 17 00:00:00 2001 From: Brett Saviano Date: Thu, 3 Apr 2025 18:36:46 -0400 Subject: [PATCH 3/3] Update CHANGELOG.md --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 3d8ce971..6efaad53 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [3.0.1] 04-Apr-2025 - Fixes - Fix issue where `Undo` after a save deletes the file being edited (#1524) + - Fix endless save loop when one local workspace folder is a subfolder of another (#1525) ## [3.0.0] 02-Apr-2025 - Enhancements