Skip to content

Commit c005634

Browse files
authored
Merge branch 'main' into flake-n-yarn
2 parents 7984fe2 + c248b20 commit c005634

File tree

2 files changed

+13
-9
lines changed

2 files changed

+13
-9
lines changed

src/commands/showPanel.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff 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);

src/utils/editor.ts

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff 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,

0 commit comments

Comments
 (0)