Skip to content

Commit

Permalink
fix(Codeblock): 🐛 Copilot isn't always right. Use indent to calcula…
Browse files Browse the repository at this point in the history
…te nodeDepth
  • Loading branch information
SkepticMystic committed Jan 11, 2022
1 parent db1ac4b commit 8d722ee
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions main.js
Original file line number Diff line number Diff line change
Expand Up @@ -26122,7 +26122,7 @@ function create_if_block_2$2(ctx) {
};
}

// (77:4) {#if meetsConditions(link)}
// (77:4) {#if meetsConditions(indent, link)}
function create_if_block$4(ctx) {
let current_block_type_index;
let if_block;
Expand Down Expand Up @@ -26382,7 +26382,7 @@ function create_if_block_1$3(ctx) {

// (76:2) {#each lines as [indent, link]}
function create_each_block$7(ctx) {
let show_if = /*meetsConditions*/ ctx[8](/*link*/ ctx[34]);
let show_if = /*meetsConditions*/ ctx[8](/*indent*/ ctx[33], /*link*/ ctx[34]);
let if_block_anchor;
let current;
let if_block = show_if && create_if_block$4(ctx);
Expand Down Expand Up @@ -26596,8 +26596,8 @@ function instance$b($$self, $$props, $$invalidate) {

const indentToDepth = indent => indent.length / 2 + 1;

const meetsConditions = node => {
const depth = indentToDepth(node.split("\n")[0]);
const meetsConditions = (indent, node) => {
const depth = indentToDepth(indent);
return depth >= min && depth <= max && (froms === undefined || froms.includes(node));
};

Expand Down
6 changes: 3 additions & 3 deletions src/Components/CBTree.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,8 @@
const indentToDepth = (indent: string) => indent.length / 2 + 1;
const meetsConditions = (node: string) => {
const depth = indentToDepth(node.split("\n")[0]);
const meetsConditions = (indent: string, node: string) => {
const depth = indentToDepth(indent);
return (
depth >= min &&
depth <= max &&
Expand All @@ -90,7 +90,7 @@
{/if}
<div class="BC-tree">
{#each lines as [indent, link]}
{#if meetsConditions(link)}
{#if meetsConditions(indent, link)}
{#if content === "open" || content === "closed"}
<div>
<pre class="indent">{indent}</pre>
Expand Down

0 comments on commit 8d722ee

Please sign in to comment.