MCPcopy Index your code
hub / github.com/ChrisFeldmeier/OpenCodeRust / is_selected

Method is_selected

crates/opencode-tui/src/ui/selection.rs:81–108  ·  view source on GitHub ↗

Test whether a specific cell is inside the selection.

(&self, row: u16, col: u16)

Source from the content-addressed store, hash-verified

79
80 /// Test whether a specific cell is inside the selection.
81 pub fn is_selected(&self, row: u16, col: u16) -> bool {
82 let ((r0, c0), (r1, c1)) = match self.range() {
83 Some(r) => r,
84 None => return false,
85 };
86
87 if row < r0 || row > r1 {
88 return false;
89 }
90
91 if r0 == r1 {
92 // Single-line selection
93 return col >= c0 && col <= c1;
94 }
95
96 if row == r0 {
97 // First row: from start col to end of line
98 return col >= c0;
99 }
100
101 if row == r1 {
102 // Last row: from start of line to end col
103 return col <= c1;
104 }
105
106 // Middle rows: entire line
107 true
108 }
109
110 /// Extract the selected text using a callback that returns the full line
111 /// content for a given row number.

Callers 1

drawMethod · 0.80

Calls 1

rangeMethod · 0.80

Tested by

no test coverage detected