Skip to content

Commit

Permalink
added correct initial value of semi for top of program
Browse files Browse the repository at this point in the history
  • Loading branch information
azizghuloum committed Nov 25, 2024
1 parent d9806a5 commit 189c517
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/pprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { list_tag } from "./AST";
import * as prettier from "prettier/standalone";
import * as prettier_ts from "prettier/plugins/typescript";
import * as prettier_estree from "prettier/plugins/estree";
import node from "tree-sitter-typescript/bindings/node";

type ns = string | ns[];

Expand All @@ -19,7 +20,7 @@ function loc_to_ns(loc: Loc): ns {
/* */

function stx_to_ns(stx: AST, semi: boolean): ns {
if (semi && stx.tag !== "other") return [stx_to_ns(stx, false), [";\n"]];
if (semi && stx.tag !== "other") return [stx_to_ns(stx, false), ";"];
switch (stx.type) {
case "list": {
const semi = children_need_semi[stx.tag] ?? false;
Expand Down Expand Up @@ -94,7 +95,10 @@ function loc_to_ns(loc: Loc): ns {
}
}

return strip_top(path_to_ns(loc.p, mark_top(stx_to_ns(loc.t, false))));
{
const semi = loc.p.type === "node" && (children_need_semi[loc.p.tag] ?? false);
return strip_top(path_to_ns(loc.p, mark_top(stx_to_ns(loc.t, semi))));
}
}

function ns_to_string(main_ns: ns) {
Expand Down

0 comments on commit 189c517

Please sign in to comment.