RakuyoKit / JSONPreview

🎨 A view that previews JSON in highlighted form, it also provides the ability to format and collapse nodes.
MIT License
65 stars 13 forks source link

Prevent "String index is out of bounds" error #3

Closed azm819 closed 2 years ago

azm819 commented 2 years ago

If you click on an empty line, an "String index is out of bounds" error is raised

rakuyoMo commented 2 years ago

Thank you very much for your contribution, but I'm curious as to what happens when there is a blank line? Can you provide a sample json, or some steps to reproduce this issue?

azm819 commented 2 years ago
  1. make jsonTextView editable: jsonPreview.jsonTextView.isEditable = true
  2. try clicking on empty jsonTextView
rakuyoMo commented 2 years ago
  • make jsonTextView editable: jsonPreview.jsonTextView.isEditable = true
  • try clicking on empty jsonTextView

Ok, I understand, I will merge this modification.

But let me be clear, JSONPreview is not developed as a JSON editor, it's just a preview view. So try not to turn on the isEditable property, it may cause a lot of unpredictable errors. And JSONPreview can't do real-time rendering of user input at the moment.