Comments (18)
Just released Ropey 1.2.0, which includes this feature.
If anyone encounters any bugs with this, please don't hesitate to open a new issue!
from ropey.
@mcobzarenco Thanks for the kind words!
I don't think it's too far off. IIRC, I already have it tracking the indices in the tree, so the remaining work is implementing the conversion functions. So, I guess it's about 50% done. But it's not a big feature--the index tracking only took a day or two, IIRC.
I got really busy part way through implementation, which is why it stalled. And then I just never got back to it. But I'm on break now, and since there's someone with an actual use-case (you!) that definitely provides motivation. So I'll get back on this soon. Thanks for the push!
I would love help with testing. I'll post here again once I've got an initial version working. If you'd be willing to test at that point I would super appreciate it.
from ropey.
@mcobzarenco All functionality is now implemented on both Rope
and RopeSlice
. If you could please test it when you get the chance, I'd really appreciate it! Also, if you have any feedback on the docs or API, please don't hesitate to let me know.
Thank you!
from ropey.
Started work on this in the utf16 branch.
from ropey.
@cessen First, awesome crate! -- I'm using it in a text editor and I would like to implement LSP support. I was curious how far do you think the utf16 branch is from a complete implementation. I am happy to help with this in any way -- I will certainly be testing quite a bit :-)
from ropey.
@cessen Thanks for the detailed response and cannot wait to try it out
from ropey.
I've implemented part of the functionality now. On Rope
there are now the following methods:
len_utf16_code_units()
char_to_utf16_code_unit()
Next up is utf16_code_unit_to_char()
, which is currently just stubbed out. And after that, adding the same methods to RopeSlice
.
from ropey.
@mcobzarenco And now Rope::utf16_code_unit_to_char()
is implemented. Hopefully this should be enough to start testing with.
Next up is to implement them on RopeSlice
as well.
And I think that will be it...? I don't expect these to be used in performance critical areas, so I'd like to keep the API surface area minimal, and just have people do multi-stage conversions if they need to e.g. go from byte or line to utf16 code unit or whatnot. Does that seem reasonable to you?
from ropey.
That's great to hear, thanks @cessen!
I don't expect these to be used in performance critical areas, so I'd like to keep the API surface area minimal
Agreed -- I hope keeping track of utf16 code points doesn't add too much of an overhead by itself.
[...] and just have people do multi-stage conversions if they need to e.g. go from byte or line to utf16 code unit or whatnot. Does that seem reasonable to you?
It seems very reasonable to me -- as you mentioned the main use case of this feature is to interact with external APIs such at LSP's. That is a slow asynchronous operation, the conversion to UTF-16 should only be used when converting a response, not inside a hot loop etc.
@mcobzarenco All functionality is now implemented on both Rope and RopeSlice. If you could please test it when you get the chance, I'd really appreciate it! Also, if you have any feedback on the docs or API, please don't hesitate to let me know.
๐ฏ I will do, although it may have to wait for the weekend or so due to work responsibilities. I will post my preliminary experience / results here.
from ropey.
Yeah, no rush at all! Please don't feel pressured. I really appreciate any time you contribute to this.
from ropey.
Just a quick note: I've merged this into the master branch now, and deleted the utf16 branch. So you can just test directly from master now.
from ropey.
@mcobzarenco Again, no rush, but I'm curious if you've had a chance to poke at this yet?
from ropey.
@cessen My apologies for the really belated reply, it's been hectic --- I haven't had a chance to come back around to this, sorry, but I have some time over the next week
from ropey.
@mcobzarenco No worries! Looking forward to your feedback (and maybe bug reports!).
from ropey.
@mcobzarenco Again, no rush, but just curious if you've had a chance to poke at this yet?
(Edit: also, just realized this was freakishly similar to my earlier comment, ha ha. Guess my phrasing is pretty consistent.)
from ropey.
@mcobzarenco I hope you're doing okay amidst the pandemic.
Secondarily: any progress on testing this out? If you don't expect to get around to it any time soon, that's totally fine, but please let me know. I'd like to get this released in not too long, so I just want to know if I should move forward or wait a little longer for your testing.
Thanks!
from ropey.
@cessen Thanks for asking -- I'm muddling through the pandemic, like most I guess.. I hope you're doing alright.
Also thank you for chasing me and I do apologise for being unresponsive. I've wanted to come back with an extensive description of my experience using the new utf-16 tracking as part of building an LSP integration (rust analyser) for a text editor.
As it turned out, that was a more distant goal than I thought when I first looked at whether ropey
supports utf-16 and unfortunately I struggled to allocate as much time as I wished. On the flip side, I've recently built a prototype that to works all ๐ฏ. I've had to make progress on other unrelated features (and bugs) to get to the LSP integration -- my only year's resolution is to switch from Emacs to it -- still very much committed :-D
I'll certainly keep you in the loop of how it goes -- even if it's taking a lot longer :-/
from ropey.
@mcobzarenco Glad you're doing okay! Luckily, I'm doing well so far. :-)
Yeah, that makes sense that something like LSP integration would take quite a bit of time. I don't think I want to wait that long to make the next release, however.
So if you have the time, could you just look over the docs for master and double-check that the utf16 APIs seem right for your use-case? I'm also open to bike shedding on the method namesโI think they're fine as-is, but it would be great to make them shorter if possible without losing too much clarity.
In any case, when you do get around to the LSP stuff, please do file bug reports if you run into any issues. I already have reasonable test coverage, I think, but... there's always room for bugs in code this complex! And real-world usage has a way of exposing such things. :-)
from ropey.
Related Issues (20)
- Insert to another rope HOT 4
- Performance issue with the redundancy operations HOT 1
- `ropey` doesn't agree with `wc` HOT 7
- Async IO support for `Rope`? HOT 1
- Chunks iterator get's confused when you change direction twice. HOT 5
- test case failed lines_exact_size_iter_04 HOT 1
- attempt to compute `0_usize - 1_usize`, which would overflow HOT 2
- RopeBuilder's Default derive creates an invalid RopeBuilder HOT 1
- `TextInfo` in `Chunks` API HOT 11
- subtract with overflow in new line iterator HOT 4
- Comparaison with Xi editor HOT 1
- Is it okay if I publish a fork of this crate that works with any type of data? HOT 3
- peek methods on iterators. HOT 3
- [Qustion]: How to get the col number of byte index HOT 1
- Lines iterated ropey is ~2x slower when highlighting ~1k lines of code than a simple Vec of Vec of chars HOT 1
- Rope Graphemes Example HOT 1
- Tests and `debug_assert!` HOT 2
- Test `pt_shrink_to_fit_01` fails on i686 HOT 14
- Chars::reversed not working as expected HOT 2
- Build rope from slices HOT 8
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from ropey.