-
-
Notifications
You must be signed in to change notification settings - Fork 58
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
Use Shift-Up & Shift-Down to navigate in lists #31
Conversation
Say your prompt is something like this, with `^` indicating your cursor position. ``` .[0].hosts[0] ^ ``` if you type `Ctl-Down`, it will become ``` .[0].hosts[1] ^ ```
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.
@charbeljc Thank you so much for proposing the introduction of a new mechanism.
I have two points to mention:
- ctrl+{up, down} is often reserved for operations on the laptop side. For example, in the default settings of MacOS, pressing ctrl+up opens mission control. Since this cannot be interrupted, I recommend using a different key binding.
- In the current implementation, pressing ctrl+{up, down} continues to move forward even if it is ineffective. I would like to use a mechanism like a ring-buffer to make it cycle (for example, if there are 3 Arrays, pressing ctrl+down would move 0 -> 1 -> 2 -> 0).
322779f
to
2b27418
Compare
Hi, I changed to shift-{up, down} and implemented cycling. Let me know what you think. |
2b27418
to
28d3b3f
Compare
@charbeljc Does this mean that the jq filter is evaluated twice in a single iteration? If so, I would like to stop that because even now, given large data, the evaluation of a single jq filter can hang, and there's no benefit that justifies making it slower by evaluating the filter more than once. The strategy I have in mind is to improve From https://github.com/ynqa/jnv/blob/v0.2.0/src/jnv.rs#L50 let suggestions = all_kinds
.iter()
.filter_map(|kind| kind.path())
.map(|segments| {
if segments.is_empty() {
".".to_string()
} else {
segments
.iter()
.map(|segment| match segment {
JsonPathSegment::Key(key) => {
if key.contains('.') || key.contains('-') || key.contains('@') {
format!(".\"{}\"", key)
} else {
format!(".{}", key)
}
}
JsonPathSegment::Index(index) => format!("[{}]", index),
})
.collect::<String>()
}
}); If the result of the filter currently points to an Array, I plan to make changes so that you can search through this |
This is not the exact same filter that's got evaluated. For instance, if your prompt is
We evaluate
Off course this don't change things performance wise... If you can achieve the same effect with enhanced suggestions, it would be great ! |
Say your prompt is something like this, with
^
indicating your cursor position.if you type
Ctl-Down
, it will become