Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Highlight erroring line #954

Merged
merged 7 commits into from
Mar 28, 2023
Merged

Highlight erroring line #954

merged 7 commits into from
Mar 28, 2023

Conversation

samdev-7
Copy link
Member

Uses a similar (janky) method to UI V1, finds and highlights the erroring line.
Resolves #797.

Examples:

image

image

@samdev-7 samdev-7 requested a review from kognise March 11, 2023 16:52
@vercel
Copy link

vercel bot commented Mar 11, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
sprig ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Mar 27, 2023 at 9:38PM (UTC)

@vercel
Copy link

vercel bot commented Mar 11, 2023

@samdev-7 is attempting to deploy a commit to the Hack Club Team on Vercel.

A member of the Team first needs to authorize it.

@samdev-7 samdev-7 added the bug Something isn't working label Mar 11, 2023
@vercel vercel bot temporarily deployed to Preview – sprig March 11, 2023 16:53 Inactive
@grymmy
Copy link
Contributor

grymmy commented Mar 15, 2023

My general thoughts on this are there could be a few comments added to explain the magic tricks being performed in this code. That being said, this definitely attempts to solve a very real problem effecting users. Would suggest the PR author to exercise the editor a bit w/ different error scenarios to see if this change reacts well to them.

Will merge when additional requested comments are added clarifying what some of these functions do.

@vercel vercel bot temporarily deployed to Preview – sprig March 15, 2023 03:23 Inactive
@vercel vercel bot temporarily deployed to Preview – sprig March 15, 2023 03:28 Inactive
@samdev-7
Copy link
Member Author

samdev-7 commented Mar 15, 2023

@grymmy I've tried adding more comments, most of the modified code is adapted from V1. I'm unsure how comments should be styled with Sprig, so please let me know if I did anything wrong.

Regarding testing, I've tried it what I can think of. Please do use the deployed preview to test out edge cases if you come up with any, thanks!

@vercel vercel bot temporarily deployed to Preview – sprig March 15, 2023 03:35 Inactive
@samdev-7
Copy link
Member Author

samdev-7 commented Mar 15, 2023

Update: It seems to have issues with nesting anonymous functions.
Sample: https://sprig.hackclub.com/share/JOU4JeHU2cGMrydlXCcD

Interestingly, the error line code detects the correct line, but somehow failes to apply the highlight.

@samdev-7
Copy link
Member Author

Apologies for the notification spam, I've attempted a fix. That error is normalized here and not the usual location, so it was missed.

@vercel vercel bot temporarily deployed to Preview – sprig March 15, 2023 03:55 Inactive
@alhardwarehyde
Copy link
Contributor

@grymmy did you see @samdev-7's comments?

Copy link
Contributor

@grymmy grymmy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

}
} else {
return { description: `Runtime Error: ${gameError.error}`, raw: gameError.error }
}
}

function findErrorLineCol(stack: string | undefined): [number | null, number | null] {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a comment that explains what this function does at a high level?


let line = null
let col = null
let location = stack.match(/<anonymous>:(.+)\)/)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a comment that explains what this function does at a high level?

}


export function highlightError(line: number) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please add a comment that explains what this function does at a high level?

@grymmy
Copy link
Contributor

grymmy commented Mar 27, 2023

@samdev-7 Okay to merge after you resolve the remaining conflict in the PR.

@vercel vercel bot temporarily deployed to Preview – sprig March 27, 2023 21:33 Inactive
@vercel vercel bot temporarily deployed to Preview – sprig March 27, 2023 21:38 Inactive
@samdev-7
Copy link
Member Author

@grymmy I have attempted to elaborate regarding comments and the merge conflicts have been resolved. Let me know if issues still persist.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Highlight errors in editor
3 participants