@@ -38,37 +38,14 @@ export class Editor {
38
38
return this . editor ?. document . getText ( ) ;
39
39
}
40
40
41
- < << << << chapter - selection
42
41
static getFilePath ( assessmentName : string , questionId : number ) : string {
43
- let workspaceFolder = config . workspaceFolder ;
44
- if ( ! workspaceFolder ) {
45
- workspaceFolder = path . join ( os . homedir ( ) , ".sourceacademy" ) ;
46
- // TODO: Prompt the user to make this folder the default, and then set back to the config store.
47
- } else if ( ! path . isAbsolute ( workspaceFolder ) ) {
48
- workspaceFolder = path . join ( os . homedir ( ) , workspaceFolder ) ;
49
- }
50
- = === ===
51
- // TODO: This method is too loaded, it's not obvious it also shows the editor
52
- static async create (
53
- workspaceLocation : VscWorkspaceLocation ,
54
- assessmentName : string,
55
- questionId : number,
56
- prepend : string = "" ,
57
- initialCode : string = "" ,
58
- ) : Promise < Editor > {
59
- const self = new Editor ( workspaceLocation , assessmentName , questionId ) ;
60
- self . assessmentName = assessmentName ;
61
- self . questionId = questionId ;
62
-
63
42
const workspaceFolder = canonicaliseLocation ( config . workspaceFolder ) ;
64
- > >>> >>> main
65
-
66
43
const filePath = path . join (
67
44
workspaceFolder ,
68
45
`${ assessmentName } _${ questionId } .js` ,
69
46
) ;
70
47
71
- return filePath
48
+ return filePath ;
72
49
}
73
50
74
51
// TODO: This method is too loaded, it's not obvious it also shows the editor
@@ -100,18 +77,6 @@ export class Editor {
100
77
await vscode . workspace . fs . readFile ( vscode . Uri . file ( filePath ) ) . then (
101
78
( value ) => {
102
79
if ( value . toString ( ) !== contents ) {
103
- < < < << << chapter - selection
104
- self . log ( "EXTENSION: Conflict detected between local and remote, prompting user to choose one" )
105
- vscode . window
106
- . showInformationMessage (
107
- "The program on file differs from the one on the Source Academy servers." +
108
- "Which program should we use? (Note that picking one will overwrite the other)" ,
109
- "Local" , "Server" )
110
- . then ( async answer => {
111
- // By default the code displayed is the local one
112
- if ( answer === "Server" ) {
113
- self . log ( 'EXTENSION: Saving program from server to file' )
114
- === = ===
115
80
self . log (
116
81
"EXTENSION: Conflict detected between local and remote, prompting user to choose one" ,
117
82
) ;
@@ -128,16 +93,10 @@ export class Editor {
128
93
// By default the code displayed is the local one
129
94
if ( answer === "Yes" ) {
130
95
self . log ( "EXTENSION: Saving program from server to file" ) ;
131
- > >>> >>> main
132
96
await vscode . workspace . fs . writeFile (
133
97
uri ,
134
98
new TextEncoder ( ) . encode ( contents ) ,
135
99
) ;
136
- < < < << << chapter - selection
137
- }
138
- } )
139
-
140
- === = ===
141
100
} else if ( answer === undefined ) {
142
101
// Modal cancelled
143
102
const message = Messages . Text (
@@ -147,7 +106,6 @@ export class Editor {
147
106
sendToFrontendWrapped ( message ) ;
148
107
}
149
108
} ) ;
150
- >>> >>> > main
151
109
}
152
110
} ,
153
111
async ( ) => {
@@ -171,27 +129,6 @@ export class Editor {
171
129
vscode . commands . executeCommand ( "editor.fold" ) ;
172
130
173
131
self . editor = editor ;
174
- << < < < << chapter - selection
175
- vscode . workspace . onDidChangeTextDocument ( ( e : vscode . TextDocumentChangeEvent ) => {
176
- if ( ! self . onChangeCallback ) {
177
- return ;
178
- }
179
- const text = editor . document . getText ( ) ;
180
- if ( e . contentChanges . length === 0 ) {
181
- self . log ( `EXTENSION: Editor's code did not change, ignoring` ) ;
182
- return ;
183
- }
184
- if ( Date . now ( ) - self . replaceTime < 1000 ) {
185
- self . log (
186
- `EXTENSION: Ignoring change event, ${ Date . now ( ) - self . replaceTime } ms since last replace` ,
187
- ) ;
188
- return ;
189
- }
190
- self . log ( `EXTENSION: Editor's code changed!` ) ;
191
- self . onChangeCallback ( self ) ;
192
- self . code = text ;
193
- } ) ;
194
- === = ===
195
132
vscode . workspace . onDidChangeTextDocument (
196
133
( e : vscode . TextDocumentChangeEvent ) => {
197
134
if ( ! self . onChangeCallback ) {
@@ -213,7 +150,6 @@ export class Editor {
213
150
self . code = text ;
214
151
} ,
215
152
) ;
216
- >>> > >>> main
217
153
return self ;
218
154
}
219
155
0 commit comments