File tree Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Expand file tree Collapse file tree 3 files changed +14
-10
lines changed Original file line number Diff line number Diff line change @@ -22,7 +22,7 @@ async function main() {
22
22
23
23
async function downloadLsp ( ) {
24
24
const outputFolder = getOutputDir ( ) ;
25
- const version = "0.1.4 " ;
25
+ const version = "0.1.8 " ;
26
26
const lspFilename = "source-lsp.js" ;
27
27
const url = `https://github.com/source-academy/source-lsp/releases/download/v${ version } /${ lspFilename } ` ;
28
28
// const url = `https://github.com/source-academy/source-lsp/releases/latest/download/${lspFilename}`;
Original file line number Diff line number Diff line change @@ -95,9 +95,10 @@ async function handleMessage(
95
95
// @ts -ignore
96
96
_ . set ( info , `["${ activeEditor . uri } "].chapter` , message . chapter ?? 1 ) ;
97
97
// TODO: message.prepend can be undefined in runtime, investigate
98
- const nPrependLines = message . prepend
99
- ? message . prepend . split ( "\n" ) . length
100
- : 0 ;
98
+ const nPrependLines =
99
+ message . prepend && message . prepend !== ""
100
+ ? message . prepend . split ( "\n" ) . length + 2 // account for start/end markers
101
+ : 0 ;
101
102
_ . set ( info , `["${ activeEditor . uri } "].prepend` , nPrependLines ) ;
102
103
context . globalState . update ( "info" , info ) ;
103
104
client . sendRequest ( "source/publishInfo" , info ) ;
Original file line number Diff line number Diff line change @@ -67,12 +67,15 @@ export class Editor {
67
67
const uri = vscode . Uri . file ( filePath ) ;
68
68
self . uri = uri . toString ( ) ;
69
69
70
- const contents = [
71
- "// PREPEND -- DO NOT EDIT" ,
72
- prepend ,
73
- "// END PREPEND" ,
74
- initialCode ,
75
- ] . join ( "\n" ) ;
70
+ const contents =
71
+ prepend !== ""
72
+ ? [
73
+ "// PREPEND -- DO NOT EDIT" ,
74
+ prepend ,
75
+ "// END PREPEND" ,
76
+ initialCode ,
77
+ ] . join ( "\n" )
78
+ : initialCode ;
76
79
77
80
await vscode . workspace . fs . readFile ( vscode . Uri . file ( filePath ) ) . then (
78
81
( ) => null ,
You can’t perform that action at this time.
0 commit comments