diff --git a/cli/src/tags.rs b/cli/src/tags.rs index 5ea00f39..5e999693 100644 --- a/cli/src/tags.rs +++ b/cli/src/tags.rs @@ -53,7 +53,8 @@ pub fn generate_tags( let source = fs::read(path)?; let t0 = Instant::now(); - for tag in context.generate_tags(tags_config, &source, Some(&cancellation_flag))? { + let (tagged, _) = context.generate_tags(tags_config, &source, Some(&cancellation_flag))?; + for tag in tagged { let tag = tag?; if !quiet { write!( diff --git a/tags/src/c_lib.rs b/tags/src/c_lib.rs index b93c69a2..84f8c97b 100644 --- a/tags/src/c_lib.rs +++ b/tags/src/c_lib.rs @@ -126,7 +126,10 @@ pub extern "C" fn ts_tagger_tag( .context .generate_tags(config, source_code, cancellation_flag) { - Ok(tags) => tags, + Ok((tags, found_error)) => { + buffer.errors_present = found_error; + tags + } Err(e) => { return match e { Error::InvalidLanguage => TSTagsError::InvalidLanguage, diff --git a/tags/src/lib.rs b/tags/src/lib.rs index c247c13e..dd55d4be 100644 --- a/tags/src/lib.rs +++ b/tags/src/lib.rs @@ -255,7 +255,7 @@ impl TagsContext { config: &'a TagsConfiguration, source: &'a [u8], cancellation_flag: Option<&'a AtomicUsize>, - ) -> Result> + 'a, Error> { + ) -> Result<(impl Iterator> + 'a, bool), Error> { self.parser .set_language(config.language) .map_err(|_| Error::InvalidLanguage)?; @@ -271,7 +271,7 @@ impl TagsContext { .matches(&config.query, tree_ref.root_node(), move |node| { &source[node.byte_range()] }); - Ok(TagsIter { + Ok((TagsIter { _tree: tree, matches, source, @@ -285,7 +285,7 @@ impl TagsContext { inherits: false, local_defs: Vec::new(), }], - }) + }, tree_ref.root_node().has_error())) } }