Skip to content

Commit

Permalink
fix(fix-fmt-cmd): Fix format command that would use stale query (#61)
Browse files Browse the repository at this point in the history
Co-authored-by: Broknloop <[email protected]>
  • Loading branch information
broknloop and joaomcclain authored Dec 11, 2023
1 parent ee2b3b5 commit 1744ec4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/main/js/components/editor/editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ function Editor({query, setQuery, handleRunQuery, handleFormatQuery}) {
if (handleFormatQuery) {
commands.push({
name: 'format query',
exec: handleFormatQuery,
exec: () => handleFormatQuery(query),
bindKey: {mac: "Command-Option-L", win: "Ctrl-Alt-L"}
})
}
editor.commands.addCommands(commands)
}
}, [editorRef?.current?.editor])
}, [editorRef?.current?.editor, query])

return (<AceEditor
ref={editorRef}
Expand Down
4 changes: 2 additions & 2 deletions src/main/js/routes/schema/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Query({containerUrl, schema}) {
runQuery()
}

function prettifyJsonQuery() {
function prettifyJsonQuery(query) {
try {
setQuery(JSON.stringify(JSON.parse(query), null, 2))
} catch (_) {
Expand Down Expand Up @@ -69,7 +69,7 @@ function Query({containerUrl, schema}) {
data-tooltip-id="vispana-tooltip"
data-tooltip-content="Format Query (Cmd+Opt+L)"
data-tooltip-place="top"
onClick={prettifyJsonQuery}>
onClick={(e) => prettifyJsonQuery(query)}>
<i className="fas fa-code "/>
</button>
<button type="button"
Expand Down

0 comments on commit 1744ec4

Please sign in to comment.