Skip to content

Commit fca7b36

Browse files
committed
prompt user to pick local or server
1 parent 24fe90e commit fca7b36

File tree

1 file changed

+17
-1
lines changed

1 file changed

+17
-1
lines changed

src/utils/editor.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,11 +71,27 @@ export class Editor {
7171
"// END PREPEND",
7272
initialCode,
7373
].join("\n");
74+
self.log(contents)
7475

7576
await vscode.workspace.fs.readFile(vscode.Uri.file(filePath)).then(
7677
(value) => {
7778
if (value.toString() !== contents) {
78-
console.log("editor code changed while offline")
79+
self.log("EXTENSION: Conflict detected between local and remote, prompting user to choose one")
80+
vscode.window
81+
.showInformationMessage(
82+
"The program on file differs from the one on the Source Academy servers." +
83+
"Which program should we use? (Note that picking one will overwrite the other)",
84+
"Local", "Server")
85+
.then(async answer => {
86+
// By default the code displayed is the local one
87+
if (answer === "Server") {
88+
await vscode.workspace.fs.writeFile(
89+
uri,
90+
new TextEncoder().encode(contents),
91+
);
92+
}
93+
})
94+
7995
}
8096
},
8197
async () => {

0 commit comments

Comments
 (0)