Skip to content

Commit

Permalink
fix: the do you want to format message popped up after clicking the "…
Browse files Browse the repository at this point in the history
…Compact" button
  • Loading branch information
josdejong committed Jun 19, 2024
1 parent 3bda70e commit 8c436ed
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions src/lib/components/modes/textmode/TextMode.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@
let onChangeDisabled = false
let acceptTooLarge = false
let askToFormatApplied = askToFormat
let validationErrors: ValidationError[] = []
const linterCompartment = new Compartment()
Expand Down Expand Up @@ -288,6 +289,8 @@
setCodeMirrorContent(updatedContent, true, false)
askToFormatApplied = askToFormat // reset to the original value
return true
} catch (err) {
onError(err as Error)
Expand All @@ -311,6 +314,8 @@
setCodeMirrorContent(updatedContent, true, false)
askToFormatApplied = false
return true
} catch (err) {
onError(err as Error)
Expand Down Expand Up @@ -1072,7 +1077,7 @@
/>
{/if}

{#if !jsonParseError && askToFormat && needsFormatting(text)}
{#if !jsonParseError && askToFormatApplied && needsFormatting(text)}
<Message
type="success"
message="Do you want to format the JSON?"
Expand All @@ -1087,7 +1092,7 @@
icon: faTimes,
text: 'No thanks',
title: 'Close this message',
onClick: () => (askToFormat = false)
onClick: () => (askToFormatApplied = false)
}
]}
onClose={focus}
Expand Down

0 comments on commit 8c436ed

Please sign in to comment.