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(
5757 // @ts -ignore
5858 _ . set ( info , `["${ activeEditor . uri } "].chapter` , message . chapter ?? 1 ) ;
5959 // 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 ;
6364 _ . set ( info , `["${ activeEditor . uri } "].prepend` , nPrependLines ) ;
6465 context . globalState . update ( "info" , info ) ;
6566 client . sendRequest ( "source/publishInfo" , info ) ;
Original file line number Diff line number Diff line change @@ -65,12 +65,15 @@ export class Editor {
6565 const uri = vscode . Uri . file ( filePath ) ;
6666 self . uri = uri . toString ( ) ;
6767
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 ;
7477
7578 await vscode . workspace . fs . readFile ( vscode . Uri . file ( filePath ) ) . then (
7679 ( ) => null ,
You can’t perform that action at this time.
0 commit comments