-
Notifications
You must be signed in to change notification settings - Fork 53
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
TextInfo
in Chunks
API
#75
Comments
Hi truchi, It's certainly not a bad idea. But I'm curious what your use case is? I'm trying to avoid adding more surface area to Ropey's already (IMO) too-large API. So without a specific concrete use case, I'm hesitant to add this. |
Hi! What I really wish to see in
but that would be a complete overhaul of the existing API (and surely you did your thing for good reasons). So I guess the easiest thing we can do to get close is to give the First example that comes to mind is (vim-like) text movement ( Thanks for your interest! |
Okay, I think I understand. A unified cursor API itself definitely doesn't belong in Ropey (Ropey is trying to be lower-level than that). But yeah, a Having said that, there are a couple of things possibly worth pointing out here:
In any case, at this point providing a
Of these options, 1 is what I'd ideally like to do. But that will need to wait for a future Ropey 2.0, and I'm not ready to do that yet because there are a bunch of other things I want to do with Ropey 2.0 as well, so it's a big project. I do think the idea is good, so it's certainly going on the list of things to do in Ropey 2.0, at the very least. But I guess I'm just not convinced that the benefits are meaningful enough to justify options 2 or 3 in Ropey 1.x. |
Hello again, Thanks for your feedback!
I'm glad all of this make sense!
I realized while doing my own toy rope with dream cursor api that line/column tracking might be extra cost if actually unused by caller... They are ways to work around that but it indeed gets specific to use cases and yeah at this point a low level rope might just give indexing to build upon.
True. I overestimate the performance impact of things! See below
I'm not
Agree about 1 & 3.
😍 That's exciting news! By the way, is Thank you! Edit: Oh, and LSP uses |
For submitting edits, I don't see how an iterator over the text would be useful...? At least, in an editor like Helix it just sends the edits as it makes them, which seems like the right approach to me. Is the use case here the initial sending of the text buffer, before any edits?
As an aside: it continues to baffle me how many popular APIs there are that require line/col offsets rather than just e.g. byte or code unit offsets from the beginning of the text. The latter provides all the information needed for text and edit exchange. And all the former does is cause compatibility problems between software that doesn't agree on what counts as lines and line breaks. Providing the option to specify text offsets by line/col is fine, of course. But requiring line/col offsets only causes problems. Both LSP and Treesitter were designed and built by people that really should have known better. Alas...
This is a lesson I learned earlier in Ropey's development (pre 1.0) when I tried to directly support grapheme segmentation. And IMO it's generally a good philosophy for library development: rather than trying to handle every use case directly, instead try to provide a good set of foundations that other people can build on top of. And that's a big part of why the chunk-related APIs are exposed in Ropey at all: it's a relatively small set of APIs that provide a lot of power for users of Ropey to build on top of. And I'd like to continue in that spirit: trying to keep the API as small as it reasonably can be, but designed well to allow people to use it in flexible ways with some extra code on their side.
Ah, that's a good point. I'll think about that!
I think so? If a node has four children, and you want the info up to the beginning of the fourth child, you just sum the info of all three children to its left, plus whatever info came from the level above. I can't imagine any reasonable definition of a rope limiting it to binary trees. Binary trees are simpler, of course, so for pedagogical reasons they're usually taught that way. But for modern hardware it's much more efficient to implement them with high-arity trees and a careful memory layout.
Just to be clear: Ropey 2.0 is completely hypothetical at this point. It's something I'd like to do eventually, but I have no estimate as to when that might be. It could be ten years from now, for all I know. |
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
This comment was marked as off-topic.
@stevefan1999-personal I still don't understand what you're talking about, and you continue to not provide any additional context or explanation. But as far as I can tell, this seems unrelated to this issue, so I'm marking the comments as off-topic. If you have a real, concrete issue, feel free to open up another issue. But if you do, please take the time to provide full context and fully explain what you're trying to do. |
Hello cessen,
How do you traverse the
Chunks
and get the byte/char/line index of those chunks?That would be awesome if
Chunks: Iterator<Item = (TextInfo, &str)>
!Is this desirable/achievable? Do you think it's a good first issue?
Thanks
The text was updated successfully, but these errors were encountered: