diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2019-10-25 12:24:43 +0100 |
---|---|---|
committer | GitHub <[email protected]> | 2019-10-25 12:24:43 +0100 |
commit | 5f779f6c46f29c63483c0e2be732377b1b87e685 (patch) | |
tree | 10e0a683d2426b7fba25bccc50f3808371202e56 /crates/ra_text_edit | |
parent | 4ab384c19d30e2ea1ead5886dfc1efc05521f075 (diff) | |
parent | d5cd8b5be2a146abe75c0aa322f2313240c8f23c (diff) |
Merge #2066
2066: insert space after `->` r=matklad a=matklad
Co-authored-by: Aleksey Kladov <[email protected]>
Diffstat (limited to 'crates/ra_text_edit')
-rw-r--r-- | crates/ra_text_edit/src/text_edit.rs | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/crates/ra_text_edit/src/text_edit.rs b/crates/ra_text_edit/src/text_edit.rs index 0381ea000..413c7d782 100644 --- a/crates/ra_text_edit/src/text_edit.rs +++ b/crates/ra_text_edit/src/text_edit.rs | |||
@@ -32,6 +32,24 @@ impl TextEditBuilder { | |||
32 | } | 32 | } |
33 | 33 | ||
34 | impl TextEdit { | 34 | impl TextEdit { |
35 | pub fn insert(offset: TextUnit, text: String) -> TextEdit { | ||
36 | let mut builder = TextEditBuilder::default(); | ||
37 | builder.insert(offset, text); | ||
38 | builder.finish() | ||
39 | } | ||
40 | |||
41 | pub fn delete(range: TextRange) -> TextEdit { | ||
42 | let mut builder = TextEditBuilder::default(); | ||
43 | builder.delete(range); | ||
44 | builder.finish() | ||
45 | } | ||
46 | |||
47 | pub fn replace(range: TextRange, replace_with: String) -> TextEdit { | ||
48 | let mut builder = TextEditBuilder::default(); | ||
49 | builder.replace(range, replace_with); | ||
50 | builder.finish() | ||
51 | } | ||
52 | |||
35 | pub(crate) fn from_atoms(mut atoms: Vec<AtomTextEdit>) -> TextEdit { | 53 | pub(crate) fn from_atoms(mut atoms: Vec<AtomTextEdit>) -> TextEdit { |
36 | atoms.sort_by_key(|a| (a.delete.start(), a.delete.end())); | 54 | atoms.sort_by_key(|a| (a.delete.start(), a.delete.end())); |
37 | for (a1, a2) in atoms.iter().zip(atoms.iter().skip(1)) { | 55 | for (a1, a2) in atoms.iter().zip(atoms.iter().skip(1)) { |