diff --git a/helper/src/html/parser.rs b/helper/src/html/parser.rs index e50eaa46..bd2eead4 100644 --- a/helper/src/html/parser.rs +++ b/helper/src/html/parser.rs @@ -37,7 +37,11 @@ impl<'a> HtmlParser<'a> { fn parse_node(&self, node: &Node) -> Option, String>> { for child_node in traverse::PreOrder::new(node.walk()) { - if child_node.kind() == "script_element" { + // Parse the script element that is surrounding the cursor. + if child_node.kind() == "script_element" && + child_node.start_position().row <= self.line - 1 && + child_node.end_position().row >= self.line - 1 + { return self.parse_script_element(&child_node); } } diff --git a/test/filetypes/svelte/hello-world.vader b/test/filetypes/svelte/hello-world.vader index 8df102d4..151cf776 100644 --- a/test/filetypes/svelte/hello-world.vader +++ b/test/filetypes/svelte/hello-world.vader @@ -5,6 +5,13 @@ Given svelte (hello world example with template and script tag): + + + Do (trigger doge): - :9\ + :16\ \ - :20\ + :27\ \ Expect typescript (generated comment with generated comment inside +