(&self, selection_num: i32)
| 1462 | } |
| 1463 | |
| 1464 | pub fn remove_selection(&self, selection_num: i32) -> Result<bool> { |
| 1465 | if selection_num != 0 { |
| 1466 | return Ok(false); |
| 1467 | } |
| 1468 | |
| 1469 | self.resolve_for_text_with_context(|node, tree, context| { |
| 1470 | // Simply collapse the selection to the position of the caret if a caret is |
| 1471 | // visible, otherwise set the selection to 0. |
| 1472 | let selection_end = node |
| 1473 | .text_selection_focus() |
| 1474 | .unwrap_or_else(|| node.document_range().start()); |
| 1475 | let (target_node, target_tree) = |
| 1476 | tree.state().locate_node(node.id()).ok_or(Error::Defunct)?; |
| 1477 | context.do_action(ActionRequest { |
| 1478 | action: Action::SetTextSelection, |
| 1479 | target_tree, |
| 1480 | target_node, |
| 1481 | data: Some(ActionData::SetTextSelection( |
| 1482 | selection_end.to_degenerate_range().to_text_selection(), |
| 1483 | )), |
| 1484 | }); |
| 1485 | Ok(true) |
| 1486 | }) |
| 1487 | } |
| 1488 | |
| 1489 | pub fn set_selection( |
| 1490 | &self, |
nothing calls this directly
no test coverage detected