Skip to content

Some playground improvements - #4213

Open
Earlopain wants to merge 2 commits into
ruby:mainfrom
Earlopain:playground-improvements
Open

Some playground improvements#4213
Earlopain wants to merge 2 commits into
ruby:mainfrom
Earlopain:playground-improvements

Conversation

@Earlopain

Copy link
Copy Markdown
Collaborator
  • Add color to empty locations
  • Fix display of string type as [Object Object]
  • Include slice for location fields
  • Add location: to node locations like in ruby inspect output

Before:
image
After:
image

* Add color to empty locations
* Fix display of string type as `[Object Object]`
* Include slice for location fields
* Add `location: ` to node locations like in ruby inspect output
Comment thread doc/playground.js Outdated
let text = `${start.line}:${start.col}-${end.line}:${end.col}`;

if (includeSlice) {
const slice = source.slice(loc.startOffset, loc.startOffset + loc.length);

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

So, this is not correct. slice does by character but the offsets are in bytes and I don't know how you'd handle this in javascript. It's already the same problem with offsetToLineCol but here it would be a bit more noticable I think

Image

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Should be ok with ffeef1e, I think

Javascript strings are always utf16, TextEncoder
converts it to utf-8 bytes.
Doing it like this seems like a fine solution
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant