nova-prettier
nova-prettier copied to clipboard
Bug: Hang/Crash with 200K JSON file
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
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.
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?
An option is definitely possible, but I don't think it's a good default as it would make format on saved completely unusable.