summaryrefslogtreecommitdiff
path: root/cli/lsp/text.rs
diff options
context:
space:
mode:
authorDavid Sherret <dsherret@users.noreply.github.com>2021-09-07 10:39:32 -0400
committerGitHub <noreply@github.com>2021-09-07 10:39:32 -0400
commit2c2e3ec1ca47803f791ea72ea6247d8eedf87ec8 (patch)
tree9ba3ddfde58f4a4feaf98fc230ec18861891c9be /cli/lsp/text.rs
parenta5bcf7033e66a828dc88a313f4cca11f116c3f83 (diff)
refactor(lsp): use deno_ast and cache swc ASTs (#11780)
Diffstat (limited to 'cli/lsp/text.rs')
-rw-r--r--cli/lsp/text.rs15
1 files changed, 3 insertions, 12 deletions
diff --git a/cli/lsp/text.rs b/cli/lsp/text.rs
index fedeabd06..0b9ae79be 100644
--- a/cli/lsp/text.rs
+++ b/cli/lsp/text.rs
@@ -210,21 +210,12 @@ impl LineIndex {
/// Compare two strings and return a vector of text edit records which are
/// supported by the Language Server Protocol.
-pub fn get_edits(
- a: &str,
- b: &str,
- maybe_line_index: Option<LineIndex>,
-) -> Vec<TextEdit> {
+pub fn get_edits(a: &str, b: &str, line_index: &LineIndex) -> Vec<TextEdit> {
if a == b {
return vec![];
}
let chunks = diff(a, b);
let mut text_edits = Vec::<TextEdit>::new();
- let line_index = if let Some(line_index) = maybe_line_index {
- line_index
- } else {
- LineIndex::new(a)
- };
let mut iter = chunks.iter().peekable();
let mut a_pos = TextSize::from(0);
loop {
@@ -575,7 +566,7 @@ const C: char = \"パ パ\";
fn test_get_edits() {
let a = "abcdefg";
let b = "a\nb\nchije\nfg\n";
- let actual = get_edits(a, b, None);
+ let actual = get_edits(a, b, &LineIndex::new(a));
assert_eq!(
actual,
vec![
@@ -613,7 +604,7 @@ const C: char = \"パ パ\";
fn test_get_edits_mbc() {
let a = "const bar = \"πŸ‘πŸ‡ΊπŸ‡ΈπŸ˜ƒ\";\nconsole.log('hello deno')\n";
let b = "const bar = \"πŸ‘πŸ‡ΊπŸ‡ΈπŸ˜ƒ\";\nconsole.log(\"hello deno\");\n";
- let actual = get_edits(a, b, None);
+ let actual = get_edits(a, b, &LineIndex::new(a));
assert_eq!(
actual,
vec![