-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
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
Marks #703
Comments
I wonder if this will intersect with our current |
Kakoune uses @oberblastmeister was interested in this, we discussed about storing these as ranges (outside registers) so we can map them through text edits. That way they behave similar to selection ranges and stay in the same place as the document changes. It's a prerequisite for snippet support. |
I really like the idea(the revised one), and I imagine once this gets implemented, it would be much easier to implement snippet support then. |
Yeah exactly, this was the intent :) It's similar to neovim's proposed It shouldn't be too hard to do, was thinking we might be able to abstract selections into a type of mark. |
Maybe this is a stupid question (I have not been following the development of helix until recently), but using marks for snippets wouldn't collide with user-defined marks, would it? Would there be separate concepts of user-defined marks and "other" marks, which would be used for things like snippets (essentially like neovim extmarks), but they would use the same stuff under the hood? Is that an accurate understanding? |
I imagine they'd be namespaced under and |
So it's not that these will be like vim marks, but also used for snippets etc., but more that they will be like neovim extmarks, and will be used for user-defined marks (similar to vim marks) as well as other things like snippets. Is that right? |
Yep, exactly. |
I'm not sure this is a good idea but I think we could re-implement |
I have some prototype working with per-document marks (you can play with it at https://github.com/carrascomj/helix/tree/feat-marks). It is not a great implementation but the point is that I don't think that working with per-register marks is very user-friendly for the kind of manipulations that I wanted to do (i.e., save selections as marks an then transform them into multi-cursors, join them, etc.). With per-register marks, like in kakoune, it is a bit cumbersome since the user has to always choose a different register after the first mark (if I am doing it right). In the per-document fashion, I can just have a common list of marks for the current text and save them with a keybind. They are also kept linked to their document when moving to another file, which I think makes sense. On the other hand, per-document marks do not work at all as actual "bookmarks". Apart from the obvious per-document constraint, the marks are not saved across editing sessions, which is a problem on its own. In addition, the snippet implementation may be more involved if they don't work by registers. Maybe, it is better to have per-register marks but with a global default mark register which can store n selections (instead of just one). The main problem with this is how to consistently define the behaviours such as when the user copies the cursor back to a mark that is in another document (the user may just lose the selections). |
The implementation just seems to recreate a jumplist? It's already possible to explicitly save to it via Markers should be stored on the document level (not the View) and then mapped through changes (just like selections) in apply so the positions get updated through document edits. So rather than Atom has a decent API for it: https://flight-manual.atom.io/api/v1.0.2/Marker/
Rather than using markers directly on the doc you can also create a |
Ok, I see. I knew it was already possible to save jumps. I was just experimenting with operations over the marks, like those explained in #2784. I am still studying the codebase so I have a couple questions about a possible Marker API. Is it required to have a On another topic, here, the equivalent to the namespace of the |
If anyone's interested, the associated PR is available to be picked up by someone else. |
@kirawi I might be interested at some point. Especially, it could be interesting to work on it by also extending hints to allow to extending / adding selections to the current sets of selections. |
Using marks to create arbitrary selections was a major workflow for me in Kakoune. Consider the following task: I have some text that I'd like to mark up, say with HTML tags. The specific items that I want to mark up don't follow an exact pattern:
Unless I'm mistaken, without resorting to an Einstein-level regex or click-and-drag, there's no way to combine all of those selections to reduce the edit to a single pair of insert and append operations (for the opening and closing tags, respectively). |
Like Vim'sm
. You can record a mark of the current position of the primary cursor in a register, and it will remember the file, and cursor position. You can then return to the mark later.Revised idea: a mark can store several selections, and returning to the mark will set all selections. As such, mark selections can be passed through operations to alter the selections. This would also mean there can be operations that take as input multiple marks (and/or the current selections).
The text was updated successfully, but these errors were encountered: