-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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 % current file register #5577
Conversation
5ebe0be
to
b9f3cc9
Compare
I think #3393 is slightly different and a lot harder to use compared to this scenario, the user has to type The one implemented here is slightly similar to what @QiBaobin implemented, except being pull based (when user select registers) rather than push based (when user change view). Now I just realized I should clear the register if user did |
b9f3cc9
to
8c3921e
Compare
The register could be useful for prompts and pickers where variable substitution might not be done (it might not make sense to replace variables if the prompt is a regex for example). Kakoune has a special register for this as well: https://github.com/mawww/kakoune/blob/master/doc/pages/registers.asciidoc#special-registers |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Kakoune has an interesting way of passing state like the current buffer name to register functions: registers are defined with an anonymous function that takes Context
and returns the value of the register. This is helpful for other special registers like 0..9
acting as regex captures. We don't need to emulate that exactly but I'm curious if we can implement this in a way that's easier to add the other special registers later
Useful to open files relative to current file.
8c3921e
to
e023dde
Compare
} | ||
|
||
impl Registers { | ||
pub fn read(&self, doc: &Document, name: char) -> Option<Vec<String>> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@the-mikedavis I did what you mentioned but now I don't like the API to always return an owned value, we need to keep cloning since the readonly function should return an owned value, unless we get it to return &str
which will limit what we can do in the future.
27be41c
to
a0ef781
Compare
Useful to open files relative to current file.
The experience is worse especially on files that have huge paths, like python virtual environment, this allows browsing relative files easier, while being a lot easier to implement compared to find file. #2412
To create new file from current file directory.
Compared to previous method (mouse copy-paste or manually type - and I usually manually type 1-7 directories)