tree-select-node to select current node
This commit is contained in:
parent
a78febec6c
commit
fc7288a27f
|
@ -54,6 +54,11 @@ define-command tree-select-parent-node -params ..1 -docstring %{
|
|||
Select the closest visible ancestor or ancestor of KIND when provided.
|
||||
} %{ tree-command-with-optional-kind SelectParentNode %arg{1} }
|
||||
|
||||
define-command tree-select-node -docstring %{
|
||||
tree-select-node
|
||||
Select the closest visible node
|
||||
} %{ tree-command-with-optional-kind SelectNode }
|
||||
|
||||
define-command tree-select-next-node -params ..1 -docstring %{
|
||||
tree-select-next-node [<KIND>]
|
||||
Select the closest visible next sibling or next sibling of KIND when provided.
|
||||
|
|
|
@ -28,6 +28,7 @@ enum Op {
|
|||
SelectNextNode { kind: Option<String> },
|
||||
SelectParentNode { kind: Option<String> },
|
||||
SelectPreviousNode { kind: Option<String> },
|
||||
SelectNode,
|
||||
}
|
||||
|
||||
fn main() {
|
||||
|
@ -106,6 +107,13 @@ fn handle_request(config: &Config, request: &Request) -> String {
|
|||
let mut new_ranges = Vec::new();
|
||||
let filetype_config = config.get_filetype_config(&request.filetype);
|
||||
match &request.op {
|
||||
Op::SelectNode => {
|
||||
for range in &ranges {
|
||||
let node = tree::shrink_to_range(tree.root_node(), range);
|
||||
new_ranges.push(node.range());
|
||||
}
|
||||
kakoune::select_ranges(&buffer, &new_ranges)
|
||||
}
|
||||
Op::SelectParentNode { kind } => {
|
||||
let kinds = kind
|
||||
.as_ref()
|
||||
|
|
Loading…
Reference in New Issue
Block a user