File tree Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Expand file tree Collapse file tree 2 files changed +13
-9
lines changed Original file line number Diff line number Diff line change @@ -57,9 +57,10 @@ async function handleMessage(
57
57
// @ts -ignore
58
58
_ . set ( info , `["${ activeEditor . uri } "].chapter` , message . chapter ?? 1 ) ;
59
59
// TODO: message.prepend can be undefined in runtime, investigate
60
- const nPrependLines = message . prepend
61
- ? message . prepend . split ( "\n" ) . length
62
- : 0 ;
60
+ const nPrependLines =
61
+ message . prepend && message . prepend !== ""
62
+ ? message . prepend . split ( "\n" ) . length + 2 // account for start/end markers
63
+ : 0 ;
63
64
_ . set ( info , `["${ activeEditor . uri } "].prepend` , nPrependLines ) ;
64
65
context . globalState . update ( "info" , info ) ;
65
66
client . sendRequest ( "source/publishInfo" , info ) ;
Original file line number Diff line number Diff line change @@ -65,12 +65,15 @@ export class Editor {
65
65
const uri = vscode . Uri . file ( filePath ) ;
66
66
self . uri = uri . toString ( ) ;
67
67
68
- const contents = [
69
- "// PREPEND -- DO NOT EDIT" ,
70
- prepend ,
71
- "// END PREPEND" ,
72
- initialCode ,
73
- ] . join ( "\n" ) ;
68
+ const contents =
69
+ prepend !== ""
70
+ ? [
71
+ "// PREPEND -- DO NOT EDIT" ,
72
+ prepend ,
73
+ "// END PREPEND" ,
74
+ initialCode ,
75
+ ] . join ( "\n" )
76
+ : initialCode ;
74
77
75
78
await vscode . workspace . fs . readFile ( vscode . Uri . file ( filePath ) ) . then (
76
79
( ) => null ,
You can’t perform that action at this time.
0 commit comments