-
-
Notifications
You must be signed in to change notification settings - Fork 116
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
Add selection - part 2 #148
Conversation
Cool, thank you! I'll have a look at it a little later. What I like about synoptic is that you can write custom syntax highlighting rules for it in the configuration file (see here), I'm not sure if the same can be done with tree-sitter. I do like the sound of moving away from the By the way - I'm happy to move back to osc52-based copy - you're right in saying that it increases the build time. This would fit nicely into the scope of this PR 👍 |
(just fixed some merge conflicts as I published a new version recently) Just a note - I'm thinking of adjusting how the repository operates Features can be implemented on PRs like this, which can then merge into a branch Do you think this sounds like a good idea? I feel like it would put less pressure on me to push full releases so quickly. |
It is possible with tree sitter, but it requires more effort (it needs compiling the grammar to a
The current edit api needs whole file parse in case of line break or selection delete. But with a rope like edit api I think it is possible to make it fast.
Good! I moved back the osc52 based copy, but for paste, I added a message to encourage users to set ctrl+v in their terminal emulator to do paste. As I said before, osc52 does have paste but it is disabled by default in most terminals, fundamentally doesn't work with tmux and zellij, and requires async communication or blocking the editor for getting the response so terminal paste is better in every way.
I'm agree that releasing version on every change is cumbersome. The dev branch could work, but is not necessary. You can merge PRs on master, and occasionally (for example every month or after some features) do some testing and polish, then make a release commit that bumps versions in Cargo.toml, do a git tag/github release like you do now, and publish the release into crates.io (and maybe distros package managers). In README you can encourage people to install ox from crates.io (that is |
Just reviewed the PR and I noticed around 3 bugs (I'll get to solving these as I am pretty confident where they are)
Also
|
So I'm pretty confident this is all good to go, let me know if you are happy for this to be merged For selection part 3, we can look at double-clicking to select words and triple-clicking to select lines like other editors do. |
I assume all is well, merging |
This PR adds support for remove text under selection with backspace and when typing something else, and adds support for cut. It uses the undo infrastructure discussed before.
While the snapshot infrastructure is very cheap performance-wise, the overall performance story is not really great. It currently reloads the whole lines cache and highlighter, and I don't see actions to improving the current state. If we hit performance problems in future, we can do these:
lines
field, together with its siblingstab_map
anddbl_map
: These requiresO(lines)
time for keeping them updated in case of line breaks and selection removes (and undo of those), and it is against the point of using rope which supports insertion and deletion inO(log length)
. It's a better idea to calculate them on demand from the rope itself for the current viewport.lines
field. Tree-sitter is a more precise (it's ast-based but synoptic is regex-based) syntax highlighter that is very fast, supports incremental parsing and has a rope-friendly api (that is, it can work with discontinuous segements of memory). It is also used in other rust based editors helix and zed.All said, I don't think performance issues are currently high priority in ox, and we are good for now. (I noticed some glitches in rendering on paste, but it is unrelated to the data structures and can be fixed by some throttling).