nova-prettier icon indicating copy to clipboard operation
nova-prettier copied to clipboard

Bug: Hang/Crash with 200K JSON file

Open FlyboyArt opened this issue 3 years ago • 3 comments

The title says it all, I have a perfectly valid JSON file (online validated @ https://jsonlint.com) and when I load it into Nova and try to Prettify it, Nova hangs and and eventually wants to shut the extension down. The file that causes the hang/crash is attached.

Other text editors seem to handle it just fine so it's just this implementation of Prettify that has trouble.

Thanks for looking into this, Art

quotes.json.gz

FlyboyArt avatar Oct 10 '21 15:10 FlyboyArt

This is because Nova doesn't support keeping the cursor position. That means the extension has to do a complete diff, which is slow for very large files or files with many/large changes. I don't think there's much that can be done about it other than providing an option to format without maintaining cursor position, but I think that's kind of confusing & weird.

alexanderweiss avatar Oct 12 '21 17:10 alexanderweiss

As opposed to crashing I think an option would be useful. The other choice ti to use a different editor for formatting JSON files which seems a waste after choosing to depend on Nova for my main editor. Perhaps placing the cursor at the top of the file after formatting by default?

FlyboyArt avatar Oct 13 '21 02:10 FlyboyArt

An option is definitely possible, but I don't think it's a good default as it would make format on saved completely unusable.

alexanderweiss avatar Oct 13 '21 16:10 alexanderweiss