From 8d722ee85a9df4fa17568cc82319d0dafd91876e Mon Sep 17 00:00:00 2001 From: Ross Keenan Date: Tue, 11 Jan 2022 21:30:21 +0200 Subject: [PATCH] fix(Codeblock): :bug: Copilot isn't always right. Use `indent` to calculate nodeDepth --- main.js | 8 ++++---- src/Components/CBTree.svelte | 6 +++--- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/main.js b/main.js index bb890321..b8b0b135 100644 --- a/main.js +++ b/main.js @@ -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; @@ -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); @@ -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)); }; diff --git a/src/Components/CBTree.svelte b/src/Components/CBTree.svelte index 1c904277..352dd958 100644 --- a/src/Components/CBTree.svelte +++ b/src/Components/CBTree.svelte @@ -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 && @@ -90,7 +90,7 @@ {/if}
{#each lines as [indent, link]} - {#if meetsConditions(link)} + {#if meetsConditions(indent, link)} {#if content === "open" || content === "closed"}
{indent}