Compare commits
No commits in common. "7a4fda31a5029a1519d899a8ff913f75e2bc093a" and "0e27fd91a744766e79b58fc64af6cd898dc7c941" have entirely different histories.
7a4fda31a5
...
0e27fd91a7
|
@ -10,11 +10,11 @@ group.type = ["abstract_type", "reference_type", "metavariable", "pointer_type",
|
|||
|
||||
[filetype.python]
|
||||
group.identifier = ["identifier"]
|
||||
group.declaration = ["function_definition", "class_definition", "decorated_definition"]
|
||||
group.statement = ["expression_statement", "for_statement", "if_statement", "return_statement", "while_statement", "raise_statement", "try_statement", "assert_statement", "import_statement", "with_statement"]
|
||||
group.declaration = ["function_definition", "class_definition"]
|
||||
group.statement = ["expression_statement", "for_statement", "if_statement", "return_statement", "while_statement", "raise_statement", "try_statement", "assert_statement", "import_statement"]
|
||||
group.call = ["call"]
|
||||
group.arguments = ["argument_list", "generator_expression"]
|
||||
group.string = ["string", "concatenated_string"]
|
||||
group.arguments = ["arguments", "parameters"]
|
||||
group.string = ["string"]
|
||||
group.number = ["integer", "float"]
|
||||
group.type = ["type", "generic_type"]
|
||||
|
||||
|
|
59
src/main.rs
59
src/main.rs
|
@ -125,45 +125,56 @@ fn handle_request(config: &Config, request: &Request) -> String {
|
|||
}
|
||||
kakoune::select_ranges(&buffer, &new_ranges)
|
||||
}
|
||||
Op::SelectNextNode { kind } | Op::SelectPreviousNode { kind } => {
|
||||
Op::SelectNextNode { kind } => {
|
||||
let kinds = kind
|
||||
.as_ref()
|
||||
.and_then(|kind| Some(filetype_config.resolve_alias(kind)));
|
||||
'outer_next: for range in &ranges {
|
||||
let node = tree::shrink_to_range(tree.root_node(), range);
|
||||
let mut cursor = node;
|
||||
let mut cursor = traverse_up_to_node_which_matters(filetype_config, node);
|
||||
loop {
|
||||
let parent = cursor.parent();
|
||||
loop {
|
||||
if filetype_config.is_node_visible(cursor) && node_of_kinds(cursor, &kinds) {
|
||||
if cursor != node {
|
||||
new_ranges.push(cursor.range());
|
||||
while let Some(node) = cursor.next_named_sibling() {
|
||||
if filetype_config.is_node_visible(node) && node_of_kinds(node, &kinds) {
|
||||
new_ranges.push(node.range());
|
||||
continue 'outer_next;
|
||||
}
|
||||
cursor = node;
|
||||
}
|
||||
if let Op::SelectNextNode { .. } = request.op {
|
||||
if let Some(next) = cursor.next_named_sibling() {
|
||||
cursor = next;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
} else {
|
||||
if let Some(prev) = cursor.prev_named_sibling() {
|
||||
cursor = prev;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(parent) = parent {
|
||||
if let Some(parent) = cursor.parent() {
|
||||
cursor = parent;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
// TODO: Do we want this behaviour?
|
||||
// let node = find_parent_of_interest(filetype_config, node, &kinds);
|
||||
// new_ranges.push(node.range());
|
||||
let node = find_parent_of_interest(filetype_config, node, &kinds);
|
||||
new_ranges.push(node.range());
|
||||
}
|
||||
kakoune::select_ranges(&buffer, &new_ranges)
|
||||
}
|
||||
Op::SelectPreviousNode { kind } => {
|
||||
let kinds = kind
|
||||
.as_ref()
|
||||
.and_then(|kind| Some(filetype_config.resolve_alias(kind)));
|
||||
'outer_prev: for range in &ranges {
|
||||
let node = tree::shrink_to_range(tree.root_node(), range);
|
||||
let mut cursor = traverse_up_to_node_which_matters(filetype_config, node);
|
||||
loop {
|
||||
while let Some(node) = cursor.prev_named_sibling() {
|
||||
if filetype_config.is_node_visible(node) && node_of_kinds(node, &kinds) {
|
||||
new_ranges.push(node.range());
|
||||
continue 'outer_prev;
|
||||
}
|
||||
cursor = node;
|
||||
}
|
||||
if let Some(parent) = cursor.parent() {
|
||||
cursor = parent;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
let node = find_parent_of_interest(filetype_config, node, &kinds);
|
||||
new_ranges.push(node.range());
|
||||
}
|
||||
kakoune::select_ranges(&buffer, &new_ranges)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user