Skip to content

Commit

Permalink
chore: remember to set the overlay value
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasRooney committed Jan 24, 2025
1 parent 0df1814 commit d10fe40
Showing 1 changed file with 17 additions and 12 deletions.
29 changes: 17 additions & 12 deletions web/src/Playground.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
} from "react";
import "./App.css";
import { Editor } from "./components/Editor";
import {editor, MarkerSeverity} from "monaco-editor";
import { editor, MarkerSeverity } from "monaco-editor";
import { ApplyOverlay, CalculateOverlay, GetInfo } from "./bridge";
import { Alert } from "@speakeasy-api/moonshine";
import { blankOverlay, petstore } from "./defaults";
Expand Down Expand Up @@ -222,26 +222,31 @@ function Playground() {
async (value: string | undefined, _: editor.IModelContentChangedEvent) => {
try {
setChangedLoading(true);
const result = await ApplyOverlay(original.current, value || "", true);
if (result.type == "success") {
result.current = value || "";
const response = await ApplyOverlay(
original.current,
result.current,
true,
);
if (response.type == "success") {
setApplyOverlayMode("original+overlay");
changed.current = result.result || "";
changed.current = response.result || "";
setError("");
setOverlayMarkers([]);
} else if (result.type == "incomplete") {
} else if (response.type == "incomplete") {
setApplyOverlayMode("jsonpathexplorer");
changed.current = result.result || "";
changed.current = response.result || "";
setError("");
setOverlayMarkers([]);
} else if (result.type == "error") {
} else if (response.type == "error") {
setApplyOverlayMode("jsonpathexplorer");
setOverlayMarkers([
{
startLineNumber: result.line,
endLineNumber: result.line,
startColumn: result.col,
endColumn: result.col + 1000, // end of line
message: result.error,
startLineNumber: response.line,
endLineNumber: response.line,
startColumn: response.col,
endColumn: response.col + 1000, // end of line
message: response.error,
severity: MarkerSeverity.Error, // Use MarkerSeverity from Monaco
},
]);
Expand Down

0 comments on commit d10fe40

Please sign in to comment.