-
Notifications
You must be signed in to change notification settings - Fork 120
Feature request - Get JSONPath based on cursor location in text mode #487
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
Comments
That would be very nice indeed, thanks for sharing your idea. I'm not sure how complex this will be to implement, we probably need a JSON parser which can translate the current caret position into the nested path of the JSON document (and the other way around). Anyone interested in figuring this out? Help would be welcome. |
You can use a json parser that will create an ast, then walk the ast and find the last node whose location contains the cursor location, then get the node path. |
The text may contain an error that prevents you from getting the path. You can't get the cursor location right now. |
This editor focuses on editing json as structured data rather than text - it's easier and more efficient. Formatting is not saved, there is not much functionality related to the text, the ast is not created or used, etc. Consider that a text mode is just an utility, it cannot be greatly improved without compromising other modes. |
Thinking about it, the editor already uses
That's simply not true. Formatting is saved, and text mode definitely is not just a utility. There already is an AST used like I explain above. What feature do you have in mind that would "compromise other modes" to implement or improve? Can you be concrete? |
Formatting is not saved - I mean, if you change the formatting in text mode (add spaces) and then change it in another mode, then this formatting will not be saved (spaces will disappear) because the json value is saved, not the ast of the text. |
I imagine it like this:
The mixed editor is more complex and requires more resources to work with, but it has more functionality. |
Ah, yes, that is true. The formatting will also be changed in text mode as soon as you apply an action like sorting or transforming. You're right that working from an AST would allow for more features like supporting JSON dialects such as json5 (with comments and stuff). The focus of Making all operations working from an AST that maintains all text formatting would be complex indeed. It would make the performance worse, and you would be limited to smaller JSON documents to prevent the AST from running out of memory. It would be nice, but I think the downsides are not worth it:
That is correct, in |
I've made a start with this in #521 |
Would love to have the ability to get the current JSONPath based on the cursor location in text mode, but I don't think with the current features/events this is possible at the moment. Is this something that can be achieved or is this too hard in text mode?
The text was updated successfully, but these errors were encountered: