aboutsummaryrefslogtreecommitdiff
path: root/src/selection.rs
diff options
context:
space:
mode:
Diffstat (limited to 'src/selection.rs')
-rw-r--r--src/selection.rs19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/selection.rs b/src/selection.rs
index 32c8807..b98a113 100644
--- a/src/selection.rs
+++ b/src/selection.rs
@@ -82,22 +82,31 @@ impl Selection {
let lines_total = end.line - start.line + 1;
for (idx, line) in buffer_lines.iter().enumerate().take(lines_total) {
- let text = line.text();
+ let text = Value::new(line.text());
let length = text.len();
if idx == 0 {
if lines_total == 1 {
value.push_str(
- &text[start.index.min(length)..end.index.min(length)],
+ &text
+ .select(
+ start.index.min(length),
+ end.index.min(length),
+ )
+ .to_string(),
);
} else {
- value.push_str(&dbg!(text)[start.index.min(length)..]);
+ value.push_str(
+ &text
+ .select(start.index.min(length), length)
+ .to_string(),
+ );
value.push_str(line.ending().as_str());
}
} else if idx == lines_total - 1 {
- value.push_str(&text[..end.index.min(length)]);
+ value.push_str(&text.until(end.index.min(length)).to_string());
} else {
- value.push_str(text);
+ value.push_str(&text.to_string());
value.push_str(line.ending().as_str());
}
}