@@ -766,7 +766,7 @@ fn trim_selections(cx: &mut Context) {
766
766
. selection ( view. id )
767
767
. iter ( )
768
768
. filter_map ( |range| {
769
- if range. is_empty ( ) || range. fragment ( text) . chars ( ) . all ( |ch| ch. is_whitespace ( ) ) {
769
+ if range. is_empty ( ) || range. slice ( text) . chars ( ) . all ( |ch| ch. is_whitespace ( ) ) {
770
770
return None ;
771
771
}
772
772
let mut start = range. from ( ) ;
@@ -1289,12 +1289,12 @@ fn replace(cx: &mut Context) {
1289
1289
1290
1290
fn switch_case_impl < F > ( cx : & mut Context , change_fn : F )
1291
1291
where
1292
- F : Fn ( Cow < str > ) -> Tendril ,
1292
+ F : Fn ( RopeSlice ) -> Tendril ,
1293
1293
{
1294
1294
let ( view, doc) = current ! ( cx. editor) ;
1295
1295
let selection = doc. selection ( view. id ) ;
1296
1296
let transaction = Transaction :: change_by_selection ( doc. text ( ) , selection, |range| {
1297
- let text: Tendril = change_fn ( range. fragment ( doc. text ( ) . slice ( ..) ) ) ;
1297
+ let text: Tendril = change_fn ( range. slice ( doc. text ( ) . slice ( ..) ) ) ;
1298
1298
1299
1299
( range. from ( ) , range. to ( ) , Some ( text) )
1300
1300
} ) ;
@@ -1320,11 +1320,15 @@ fn switch_case(cx: &mut Context) {
1320
1320
}
1321
1321
1322
1322
fn switch_to_uppercase ( cx : & mut Context ) {
1323
- switch_case_impl ( cx, |string| string. to_uppercase ( ) . into ( ) ) ;
1323
+ switch_case_impl ( cx, |string| {
1324
+ string. chunks ( ) . map ( |chunk| chunk. to_uppercase ( ) ) . collect ( )
1325
+ } ) ;
1324
1326
}
1325
1327
1326
1328
fn switch_to_lowercase ( cx : & mut Context ) {
1327
- switch_case_impl ( cx, |string| string. to_lowercase ( ) . into ( ) ) ;
1329
+ switch_case_impl ( cx, |string| {
1330
+ string. chunks ( ) . map ( |chunk| chunk. to_lowercase ( ) ) . collect ( )
1331
+ } ) ;
1328
1332
}
1329
1333
1330
1334
pub fn scroll ( cx : & mut Context , offset : usize , direction : Direction ) {
@@ -3903,8 +3907,8 @@ fn rotate_selection_contents(cx: &mut Context, direction: Direction) {
3903
3907
3904
3908
let selection = doc. selection ( view. id ) ;
3905
3909
let mut fragments: Vec < _ > = selection
3906
- . fragments ( text)
3907
- . map ( |fragment| Tendril :: from ( fragment. as_ref ( ) ) )
3910
+ . slices ( text)
3911
+ . map ( |fragment| fragment. chunks ( ) . collect ( ) )
3908
3912
. collect ( ) ;
3909
3913
3910
3914
let group = count
@@ -4510,8 +4514,8 @@ fn shell_keep_pipe(cx: &mut Context) {
4510
4514
let text = doc. text ( ) . slice ( ..) ;
4511
4515
4512
4516
for ( i, range) in selection. ranges ( ) . iter ( ) . enumerate ( ) {
4513
- let fragment = range. fragment ( text) ;
4514
- let ( _output, success) = match shell_impl ( shell, input, Some ( fragment. as_bytes ( ) ) ) {
4517
+ let fragment = range. slice ( text) ;
4518
+ let ( _output, success) = match shell_impl ( shell, input, Some ( fragment) ) {
4515
4519
Ok ( result) => result,
4516
4520
Err ( err) => {
4517
4521
cx. editor . set_error ( err. to_string ( ) ) ;
@@ -4542,7 +4546,7 @@ fn shell_keep_pipe(cx: &mut Context) {
4542
4546
fn shell_impl (
4543
4547
shell : & [ String ] ,
4544
4548
cmd : & str ,
4545
- input : Option < & [ u8 ] > ,
4549
+ input : Option < RopeSlice > ,
4546
4550
) -> anyhow:: Result < ( Tendril , bool ) > {
4547
4551
use std:: io:: Write ;
4548
4552
use std:: process:: { Command , Stdio } ;
@@ -4564,7 +4568,9 @@ fn shell_impl(
4564
4568
} ;
4565
4569
if let Some ( input) = input {
4566
4570
let mut stdin = process. stdin . take ( ) . unwrap ( ) ;
4567
- stdin. write_all ( input) ?;
4571
+ for chunk in input. chunks ( ) {
4572
+ stdin. write_all ( chunk. as_bytes ( ) ) ?;
4573
+ }
4568
4574
}
4569
4575
let output = process. wait_with_output ( ) ?;
4570
4576
@@ -4593,8 +4599,8 @@ fn shell(cx: &mut compositor::Context, cmd: &str, behavior: &ShellBehavior) {
4593
4599
let text = doc. text ( ) . slice ( ..) ;
4594
4600
4595
4601
for range in selection. ranges ( ) {
4596
- let fragment = range. fragment ( text) ;
4597
- let ( output, success) = match shell_impl ( shell, cmd, pipe. then ( || fragment. as_bytes ( ) ) ) {
4602
+ let fragment = range. slice ( text) ;
4603
+ let ( output, success) = match shell_impl ( shell, cmd, pipe. then ( || fragment) ) {
4598
4604
Ok ( result) => result,
4599
4605
Err ( err) => {
4600
4606
cx. editor . set_error ( err. to_string ( ) ) ;
0 commit comments