Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions src/commands/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {
notNull,
outputChannel,
RateLimiter,
replaceFile,
routineNameTypeRegex,
} from "../utils";
import { StudioActions } from "./studio";
Expand Down Expand Up @@ -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);
Expand Down
13 changes: 11 additions & 2 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ import {
isClassOrRtn,
addWsServerRootFolderData,
getWsFolder,
replaceFile,
} from "./utils";
import { ObjectScriptDiagnosticProvider } from "./providers/ObjectScriptDiagnosticProvider";
import { DocumentLinkProvider } from "./providers/DocumentLinkProvider";
Expand Down Expand Up @@ -1272,7 +1271,17 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
// 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);
})
);
}),
Expand Down