Skip to content

Commit aa680a5

Browse files
committed
Overwrite from Server command should always replace the entire class text
1 parent 4affd77 commit aa680a5

File tree

3 files changed

+15
-5
lines changed

3 files changed

+15
-5
lines changed

src/commands/compile.ts

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,16 @@ function updateOthers(others: string[], baseUri: vscode.Uri) {
218218
});
219219
}
220220

221-
export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]): Promise<any> {
221+
/**
222+
* Pull changes due to save/compile from server and write them into the local file.
223+
* Also used to refresh the local copy from the server outside of the save/compile workflow.
224+
* Pass `forceRefreshClasses` to replace the entire text of classes regardless of the
225+
* value of the `objectscript.refreshClassesOnSync` setting.
226+
*/
227+
export async function loadChanges(
228+
files: (CurrentTextFile | CurrentBinaryFile)[],
229+
forceRefreshClasses = false
230+
): Promise<any> {
222231
if (!files.length) {
223232
return;
224233
}
@@ -236,7 +245,8 @@ export async function loadChanges(files: (CurrentTextFile | CurrentBinaryFile)[]
236245
if (
237246
!(
238247
isClass(file.uri.path) &&
239-
!vscode.workspace.getConfiguration("objectscript", file.uri).get("refreshClassesOnSync")
248+
!vscode.workspace.getConfiguration("objectscript", file.uri).get("refreshClassesOnSync") &&
249+
!forceRefreshClasses
240250
)
241251
) {
242252
content = (await api.getDoc(file.name, file.uri)).result.content;

src/extension.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1142,7 +1142,7 @@ export async function activate(context: vscode.ExtensionContext): Promise<any> {
11421142
const file = currentFile();
11431143
if (!file) return;
11441144
try {
1145-
await loadChanges([file]);
1145+
await loadChanges([file], true);
11461146
} catch (error) {
11471147
handleError(
11481148
error,

src/providers/LowCodeEditorProvider.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ export class LowCodeEditorProvider implements vscode.CustomTextEditorProvider {
243243
});
244244
} else if (isClientSide) {
245245
// Load changes
246-
loadChanges([file]);
246+
loadChanges([file], true);
247247
}
248248
return;
249249
case "compiled":
@@ -253,7 +253,7 @@ export class LowCodeEditorProvider implements vscode.CustomTextEditorProvider {
253253
vscode.commands.executeCommand("workbench.action.files.revert");
254254
}
255255
// Load changes
256-
if (isClientSide) loadChanges([file]);
256+
if (isClientSide) loadChanges([file], true);
257257
return;
258258
case "userAction": {
259259
// Process the source control user action

0 commit comments

Comments
 (0)