Skip to content

Commit 06abb75

Browse files
authored
Merge branch 'main' into overwrite-fix
2 parents dbf4660 + 93d9e4a commit 06abb75

File tree

10 files changed

+3612
-2273
lines changed

10 files changed

+3612
-2273
lines changed

.github/workflows/check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ jobs:
1414
node-version: 20
1515
cache: yarn
1616
- name: Install dependencies
17-
run: yarn install --frozen-lockfile
17+
run: yarn install --immutable
1818
- name: Lint
1919
# TODO: Add proper linting command
2020
run: yarn format
@@ -31,6 +31,6 @@ jobs:
3131
node-version: 20
3232
cache: yarn
3333
- name: Install dependencies
34-
run: yarn install --frozen-lockfile
34+
run: yarn install --immutable
3535
- name: Test
3636
run: yarn test

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ jobs:
4141
node-version: 20
4242
cache: yarn
4343
- name: Install dependencies
44-
run: yarn install --frozen-lockfile
44+
run: yarn install --immutable
4545

4646
- name: Package
4747
run: yarn run package

.gitignore

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,27 @@
11
# Flakes
22
.direnv/
33

4-
# Node dependencies
5-
node_modules/
4+
# Yarn Berry
5+
.pnp.*
6+
.yarn/*
7+
!.yarn/patches
8+
!.yarn/plugins
9+
!.yarn/releases
10+
!.yarn/sdks
11+
!.yarn/versions
12+
13+
# Intermediate files
14+
syntaxes/source.tmLanguage.json
615

716
# Build artifacts
817
out/
918
*.vsix
10-
syntaxes/source.tmLanguage.json
1119

1220
# Logs
1321
yarn-error.log
1422

1523
# Misc
1624
.DS_Store
25+
26+
# No longer needed
27+
node_modules/

.yarnrc.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
nodeLinker: node-modules

flake.lock

Lines changed: 38 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 21 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +1,25 @@
11
{
2-
description = "Template for a direnv shell, with NodeJS";
2+
description = "nix-direnv shell for developing Source Academy's VS Code extension";
33

4-
inputs = {
5-
nixpkgs.url = "github:NixOS/nixpkgs/23.11";
6-
};
4+
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
5+
inputs.flake-utils.url = "github:numtide/flake-utils";
76

8-
outputs = { self, nixpkgs }:
9-
let
10-
system = "x86_64-linux";
11-
pkgs = import nixpkgs { inherit system; config.allowUnfree = true; };
12-
in
13-
{
14-
devShells.${system}.default = pkgs.mkShell {
15-
packages = with pkgs; [
16-
nodejs_20
17-
(yarn.override {
18-
nodejs = nodejs_20;
19-
})
20-
21-
# The following is only needed by js-slang, to remove in the future
22-
# Additional libs needed by yarn when installing
23-
pkg-config
24-
xorg.libX11
25-
xorg.libXi
26-
libGL
27-
28-
python310
29-
xorg.libXext
30-
31-
gcc11
32-
];
33-
};
34-
};
7+
outputs = {
8+
nixpkgs,
9+
flake-utils,
10+
...
11+
}:
12+
flake-utils.lib.eachDefaultSystem (
13+
system: let
14+
pkgs = nixpkgs.legacyPackages.${system};
15+
in {
16+
devShells.default = pkgs.mkShell {
17+
packages = with pkgs; [
18+
# For dev ease of use, follow NodeJS version in source-academy/frontend
19+
nodejs_20
20+
(yarn-berry.override {nodejs = nodejs_20;})
21+
];
22+
};
23+
}
24+
);
3525
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
"download-lsp": "node scripts/lsp.js",
8686
"format": "yarn prettier . --write",
8787
"vscode:prepublish": "yarn run download-lsp && yarn run build",
88-
"package": "vsce package",
88+
"package": "vsce package --no-dependencies",
8989
"test:syntax": "yarn run build:syntax && vscode-tmgrammar-test ./tests/syntaxes/*",
9090
"test": "yarn test:syntax"
9191
},

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
(value) => {

0 commit comments

Comments
 (0)