From 5749e1b65a86cb035a8e4809e7383a98619b0984 Mon Sep 17 00:00:00 2001 From: Norbert Preining Date: Thu, 11 Nov 2021 03:00:56 +0000 Subject: CTAN sync 202111110300 --- support/texlab/CHANGELOG.md | 9 + support/texlab/Cargo.lock | 26 +-- support/texlab/Cargo.toml | 10 +- support/texlab/src/diagnostics/build_log.rs | 12 +- support/texlab/src/features/completion.rs | 8 +- support/texlab/src/features/cursor.rs | 17 +- support/texlab/src/syntax/build_log.rs | 186 +++++++++++++++++++++ support/texlab/src/syntax/latex/kind.rs | 1 - support/texlab/src/syntax/latex/lexer.rs | 5 +- support/texlab/src/syntax/latex/parser.rs | 20 +-- ...atex__lexer__tests__command_with_parameter.snap | 2 +- ...ax__latex__lexer__tests__invalid_parameter.snap | 2 +- ...__parser__tests__command_definition_simple.snap | 3 +- ..._parser__tests__label_reference_incomplete.snap | 33 ++++ ...b__syntax__latex__parser__tests__parameter.snap | 3 +- ...tax__latex__parser__tests__parameter_error.snap | 3 +- ...exlab__syntax__build_log__tests__parse_007.snap | 15 ++ support/texlab/src/workspace/api.rs | 2 +- support/texlab/tests/integration/completion.rs | 8 +- support/texlab/tests/integration/issues.rs | 20 +++ ...sues__510_completion_with_unmatched_braces.snap | 57 +++++++ support/texlab/texlab.pdf | Bin 26161 -> 88770 bytes 22 files changed, 387 insertions(+), 55 deletions(-) create mode 100644 support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__label_reference_incomplete.snap create mode 100644 support/texlab/src/syntax/snapshots/texlab__syntax__build_log__tests__parse_007.snap create mode 100644 support/texlab/tests/integration/snapshots/integration__issues__510_completion_with_unmatched_braces.snap (limited to 'support/texlab') diff --git a/support/texlab/CHANGELOG.md b/support/texlab/CHANGELOG.md index 22934a08fe..13b1cc799c 100644 --- a/support/texlab/CHANGELOG.md +++ b/support/texlab/CHANGELOG.md @@ -5,6 +5,15 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [3.3.1] - 10.11.2021 + +### Fixed + +- Fix completion for symbols in commands with incomplete braces ([#510](https://github.com/latex-lsp/texlab/issues/510)) +- Do not produce syntax errors for macro parameters inside special command arguments ([#508](https://github.com/latex-lsp/texlab/issues/508)) +- Fix a bug that sometimes causes the `aux` file to pick up the diagnostics of the `tex` file ([#502](https://github.com/latex-lsp/texlab/issues/502)) +- Fix a bug that sometimes prevents `log` files from being reanalyzed ([#502](https://github.com/latex-lsp/texlab/issues/502)) + ## [3.3.0] - 10.10.2021 ### Added diff --git a/support/texlab/Cargo.lock b/support/texlab/Cargo.lock index 45a9114cc4..b5815c3ff4 100644 --- a/support/texlab/Cargo.lock +++ b/support/texlab/Cargo.lock @@ -51,9 +51,9 @@ checksum = "70033777eb8b5124a81a1889416543dddef2de240019b674c81285a2635a7e1e" [[package]] name = "anyhow" -version = "1.0.44" +version = "1.0.45" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "61604a8f862e1d5c3229fdd78f8b02c68dcf73a4c4b05fd636d12240aaa242c1" +checksum = "ee10e43ae4a853c0a3591d4e2ada1719e553be18199d9da9d4a83f5927c2f5c7" [[package]] name = "atty" @@ -464,9 +464,9 @@ checksum = "a357d28ed41a50f9c765dbfe56cbc04a64e53e5fc58ba79fbc34c10ef3df831f" [[package]] name = "encoding_rs" -version = "0.8.28" +version = "0.8.29" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80df024fbc5ac80f87dfef0d9f5209a252f2a497f7f42944cff24d8253cac065" +checksum = "a74ea89a0a1b98f6332de42c95baff457ada66d1cb4030f9ff151b2041a1c746" dependencies = [ "cfg-if 1.0.0", ] @@ -1629,9 +1629,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.68" +version = "1.0.69" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0f690853975602e1bfe1ccbf50504d67174e3bcf340f23b5ea9992e0587a52d8" +checksum = "e466864e431129c7e0d3476b92f20458e5879919a0596c6472738d9fa2d342f8" dependencies = [ "itoa", "ryu", @@ -1700,9 +1700,9 @@ dependencies = [ [[package]] name = "smol_str" -version = "0.1.18" +version = "0.1.21" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b203e79e90905594272c1c97c7af701533d42adaab0beb3859018e477d54a3b0" +checksum = "61d15c83e300cce35b7c8cd39ff567c1ef42dde6d4a1a38dbdbf9a59902261bd" dependencies = [ "serde", ] @@ -1769,9 +1769,9 @@ checksum = "8ea5119cdb4c55b55d432abb513a0429384878c15dde60cc77b1c99de1a95a6a" [[package]] name = "structopt" -version = "0.3.23" +version = "0.3.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bf9d950ef167e25e0bdb073cf1d68e9ad2795ac826f2f3f59647817cf23c0bfa" +checksum = "40b9788f4202aa75c240ecc9c15c65185e6a39ccdeb0fd5d008b98825464c87c" dependencies = [ "clap", "lazy_static", @@ -1780,9 +1780,9 @@ dependencies = [ [[package]] name = "structopt-derive" -version = "0.4.16" +version = "0.4.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "134d838a2c9943ac3125cf6df165eda53493451b719f3255b2a26b85f772d0ba" +checksum = "dcb5ae327f9cc13b68763b5749770cb9e048a99bd9dfdfa58d0cf05d5f64afe0" dependencies = [ "heck", "proc-macro-error", @@ -1863,7 +1863,7 @@ dependencies = [ [[package]] name = "texlab" -version = "3.3.0" +version = "3.3.1" dependencies = [ "anyhow", "bibutils-sys", diff --git a/support/texlab/Cargo.toml b/support/texlab/Cargo.toml index 13a27a8bd0..cf99f7b387 100644 --- a/support/texlab/Cargo.toml +++ b/support/texlab/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "texlab" description = "LaTeX Language Server" -version = "3.3.0" +version = "3.3.1" license = "GPL-3.0" readme = "README.md" authors = [ @@ -29,7 +29,7 @@ citation = [ semantic = [] [dependencies] -anyhow = "1.0.44" +anyhow = "1.0.45" bibutils-sys = { version="0.1.1", optional=true } byteorder = "1.4.3" cancellation = "0.1" @@ -42,7 +42,7 @@ csl = { git="https://github.com/cormacrelf/citeproc-rs", rev="5252fbd8d2046a5a7d crossbeam-channel = "0.5.1" cstree = "0.6.1" derive_more = "0.99.16" -encoding_rs = "0.8.28" +encoding_rs = "0.8.29" encoding_rs_io = "0.1.7" flate2 = "1.0.22" fern = "0.6" @@ -62,9 +62,9 @@ rayon = "1.5.1" regex = "1.5.4" rustc-hash = "1.1.0" serde = "1.0.130" -serde_json = "1.0.68" +serde_json = "1.0.69" serde_repr = "0.1.7" -smol_str = { version="0.1.18", features=["serde"] } +smol_str = { version="0.1.21", features=["serde"] } structopt = "0.3" tempfile = "3.2.0" threadpool = "1.8.1" diff --git a/support/texlab/src/diagnostics/build_log.rs b/support/texlab/src/diagnostics/build_log.rs index a2069ff762..ede3a873a8 100644 --- a/support/texlab/src/diagnostics/build_log.rs +++ b/support/texlab/src/diagnostics/build_log.rs @@ -15,11 +15,13 @@ pub fn analyze_build_log_static( let root_document = workspace.documents().into_iter().find(|document| { if let Some(data) = document.data.as_latex() { - data.extras - .implicit_links - .log - .iter() - .any(|u| u.as_ref() == build_log_uri) + !document.uri.as_str().ends_with(".aux") + && data + .extras + .implicit_links + .log + .iter() + .any(|u| u.as_ref() == build_log_uri) } else { false } diff --git a/support/texlab/src/features/completion.rs b/support/texlab/src/features/completion.rs index f9ad8554cd..cb6a66f3cd 100644 --- a/support/texlab/src/features/completion.rs +++ b/support/texlab/src/features/completion.rs @@ -24,6 +24,7 @@ use std::borrow::Cow; use cancellation::CancellationToken; use cstree::TextSize; use fuzzy_matcher::{skim::SkimMatcherV2, FuzzyMatcher}; +use itertools::Itertools; use lsp_types::{ CompletionItem, CompletionList, CompletionParams, CompletionTextEdit, Documentation, InsertTextFormat, MarkupContent, MarkupKind, TextEdit, @@ -159,7 +160,12 @@ fn score(context: &CursorContext, items: &mut Vec { if let Some(key) = latex::Key::cast(token.parent()) { - key.to_string().into() + key.words() + .take_while(|word| word.text_range() != token.text_range()) + .chain(std::iter::once(token)) + .filter(|word| word.text_range().start() < context.offset) + .join(" ") + .into() } else { token.text().into() } diff --git a/support/texlab/src/features/cursor.rs b/support/texlab/src/features/cursor.rs index 6e8719987a..d8db0f2aa8 100644 --- a/support/texlab/src/features/cursor.rs +++ b/support/texlab/src/features/cursor.rs @@ -264,8 +264,21 @@ impl CursorContext

{ let group = latex::CurlyGroupWordList::cast(group) .filter(|group| self.is_inside_latex_curly(group))?; - key.map(|key| (key.to_string(), key.small_range(), group)) - .or_else(|| Some((String::new(), TextRange::empty(self.offset), group))) + key.map(|key| { + let range = if group + .syntax() + .last_token() + .filter(|tok| tok.kind() == latex::MISSING) + .is_some() + { + TextRange::new(key.small_range().start(), token.text_range().end()) + } else { + key.small_range() + }; + + (key.to_string(), range, group) + }) + .or_else(|| Some((String::new(), TextRange::empty(self.offset), group))) } } diff --git a/support/texlab/src/syntax/build_log.rs b/support/texlab/src/syntax/build_log.rs index 65a5938262..f91ce974d0 100644 --- a/support/texlab/src/syntax/build_log.rs +++ b/support/texlab/src/syntax/build_log.rs @@ -183,6 +183,7 @@ impl PartialOrd for FileRange { mod tests { use super::*; use indoc::indoc; + use insta::assert_debug_snapshot; #[test] fn test_parse_001() { @@ -1158,4 +1159,189 @@ mod tests { ] ); } + + #[test] + fn test_parse_007() { + let log = indoc! { + r#" + This is pdfTeX, Version 3.141592653-2.6-1.40.22 (TeX Live 2021/W32TeX) (preloaded format=pdflatex 2021.6.19) 5 NOV 2021 19:10 + entering extended mode + restricted \write18 enabled. + %&-line parsing enabled. + **/some/folder/a.tex + (/some/folder/a.tex + LaTeX2e <2021-06-01> patch level 1 + L3 programming layer <2021-06-18> + (/texlive/2021/texmf-dist/tex/latex/koma-script/scrartcl.cls + Document Class: scrartcl 2021/03/17 v3.33 KOMA-Script document class (article) + (/texlive/2021/texmf-dist/tex/latex/koma-script/scrkbase.sty + Package: scrkbase 2021/03/17 v3.33 KOMA-Script package (KOMA-Script-dependent b + asics and keyval usage) + + (/texlive/2021/texmf-dist/tex/latex/koma-script/scrbase.sty + Package: scrbase 2021/03/17 v3.33 KOMA-Script package (KOMA-Script-independent + basics and keyval usage) + + (/texlive/2021/texmf-dist/tex/latex/koma-script/scrlfile.sty + Package: scrlfile 2021/03/17 v3.33 KOMA-Script package (file load hooks) + + (/texlive/2021/texmf-dist/tex/latex/koma-script/scrlfile-hook.sty + Package: scrlfile-hook 2021/03/17 v3.33 KOMA-Script package (using LaTeX hooks) + + + (/texlive/2021/texmf-dist/tex/latex/koma-script/scrlogo.sty + Package: scrlogo 2021/03/17 v3.33 KOMA-Script package (logo) + ))) + (/texlive/2021/texmf-dist/tex/latex/graphics/keyval.sty + Package: keyval 2014/10/28 v1.15 key=value parser (DPC) + \KV@toks@=\toks16 + ) + Applying: [2021/05/01] Usage of raw option list on input line 252. + Already applied: [0000/00/00] compatibility for LaTeX before 2021/05/01 on inpu + t line 337. + )) + ==> First Aid for scrkbase.sty no longer applied! + (/texlive/2021/texmf-dist/tex/latex/koma-script/tocbasic.sty + Package: tocbasic 2021/03/17 v3.33 KOMA-Script package (handling toc-files) + \scr@dte@tocline@numberwidth=\skip47 + \scr@dte@tocline@numbox=\box50 + ) + Package tocbasic Info: babel extension for `toc' omitted + (tocbasic) because of missing \bbl@set@language on input line 135. + Class scrartcl Info: File `scrsize11pt.clo' used instead of + (scrartcl) file `scrsize11.clo' to setup font sizes on input line 223 + 9. + + (/texlive/2021/texmf-dist/tex/latex/koma-script/scrsize11pt.clo + File: scrsize11pt.clo 2021/03/17 v3.33 KOMA-Script font size class option (11pt + ) + ) + (/texlive/2021/texmf-dist/tex/latex/koma-script/typearea.sty + Package: typearea 2021/03/17 v3.33 KOMA-Script package (type area) + \ta@bcor=\skip48 + \ta@div=\count182 + \ta@hblk=\skip49 + \ta@vblk=\skip50 + \ta@temp=\skip51 + \footheight=\skip52 + Package typearea Info: These are the values describing the layout: + (typearea) DIV = 10 + (typearea) BCOR = 0.0pt + (typearea) \paperwidth = 597.50793pt + (typearea) \textwidth = 418.25555pt + (typearea) DIV departure = -6% + (typearea) \evensidemargin = 17.3562pt + (typearea) \oddsidemargin = 17.3562pt + (typearea) \paperheight = 845.04694pt + (typearea) \textheight = 595.80026pt + (typearea) \topmargin = -25.16531pt + (typearea) \headheight = 17.0pt + (typearea) \headsep = 20.40001pt + (typearea) \topskip = 11.0pt + (typearea) \footskip = 47.6pt + (typearea) \baselineskip = 13.6pt + (typearea) on input line 1741. + ) + \c@part=\count183 + \c@section=\count184 + \c@subsection=\count185 + \c@subsubsection=\count186 + \c@paragraph=\count187 + \c@subparagraph=\count188 + \scr@dte@section@maxnumwidth=\skip53 + Class scrartcl Info: using compatibility default `runin=bysign' + (scrartcl) for `\section on input line 4846. + Class scrartcl Info: using compatibility default `afterindent=bysign' + (scrartcl) for `\section on input line 4846. + \scr@dte@part@maxnumwidth=\skip54 + Class scrartcl Info: using compatibility default `afterindent=false' + (scrartcl) for `\part on input line 4854. + \scr@dte@subsection@maxnumwidth=\skip55 + Class scrartcl Info: using compatibility default `runin=bysign' + (scrartcl) for `\subsection on input line 4864. + Class scrartcl Info: using compatibility default `afterindent=bysign' + (scrartcl) for `\subsection on input line 4864. + \scr@dte@subsubsection@maxnumwidth=\skip56 + Class scrartcl Info: using compatibility default `runin=bysign' + (scrartcl) for `\subsubsection on input line 4874. + Class scrartcl Info: using compatibility default `afterindent=bysign' + (scrartcl) for `\subsubsection on input line 4874. + \scr@dte@paragraph@maxnumwidth=\skip57 + Class scrartcl Info: using compatibility default `runin=bysign' + (scrartcl) for `\paragraph on input line 4885. + Class scrartcl Info: using compatibility default `afterindent=bysign' + (scrartcl) for `\paragraph on input line 4885. + \scr@dte@subparagraph@maxnumwidth=\skip58 + Class scrartcl Info: using compatibility default `runin=bysign' + (scrartcl) for `\subparagraph on input line 4895. + Class scrartcl Info: using compatibility default `afterindent=bysign' + (scrartcl) for `\subparagraph on input line 4895. + \abovecaptionskip=\skip59 + \belowcaptionskip=\skip60 + \c@pti@nb@sid@b@x=\box51 + Package tocbasic Info: babel extension for `lof' omitted + (tocbasic) because of missing \bbl@set@language on input line 6127. + + \scr@dte@figure@maxnumwidth=\skip61 + \c@figure=\count189 + Package tocbasic Info: babel extension for `lot' omitted + (tocbasic) because of missing \bbl@set@language on input line 6139. + + \scr@dte@table@maxnumwidth=\skip62 + \c@table=\count190 + Class scrartcl Info: Redefining `\numberline' on input line 6303. + \bibindent=\dimen138 + ) + (/texlive/2021/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def + File: l3backend-pdftex.def 2021-05-07 L3 backend support: PDF output (pdfTeX) + \l__color_backend_stack_int=\count191 + \l__pdf_internal_box=\box52 + ) (./a.aux) + \openout1 = `a.aux'. + + LaTeX Font Info: Checking defaults for OML/cmm/m/it on input line 3. + LaTeX Font Info: ... okay on input line 3. + LaTeX Font Info: Checking defaults for OMS/cmsy/m/n on input line 3. + LaTeX Font Info: ... okay on input line 3. + LaTeX Font Info: Checking defaults for OT1/cmr/m/n on input line 3. + LaTeX Font Info: ... okay on input line 3. + LaTeX Font Info: Checking defaults for T1/cmr/m/n on input line 3. + LaTeX Font Info: ... okay on input line 3. + LaTeX Font Info: Checking defaults for TS1/cmr/m/n on input line 3. + LaTeX Font Info: ... okay on input line 3. + LaTeX Font Info: Checking defaults for OMX/cmex/m/n on input line 3. + LaTeX Font Info: ... okay on input line 3. + LaTeX Font Info: Checking defaults for U/cmr/m/n on input line 3. + LaTeX Font Info: ... okay on input line 3. + Package scrbase Info: activating english \contentsname on input line 3. + Package scrbase Info: activating english \listfigurename on input line 3. + Package scrbase Info: activating english \listtablename on input line 3. + ! Undefined control sequence. + l.4 \lsdkfjlskdfj + + The control sequence at the end of the top line + of your error message was never \def'ed. If you have + misspelled it (e.g., `\hobx'), type `I' and the correct + spelling (e.g., `I\hbox'). Otherwise just continue, + and I'll forget about whatever was undefined. + + (./a.aux) ) + Here is how much of TeX's memory you used: + 3199 strings out of 478510 + 74549 string characters out of 5853586 + 510929 words of memory out of 5000000 + 21227 multiletter control sequences out of 15000+600000 + 403730 words of font info for 28 fonts, out of 8000000 for 9000 + 1141 hyphenation exceptions out of 8191 + 108i,1n,108p,10625b,270s stack positions out of 5000i,500n,10000p,200000b,80000s + + No pages of output. + PDF statistics: + 0 PDF objects out of 1000 (max. 8388607) + 0 named destinations out of 1000 (max. 500000) + 1 words of extra memory for PDF output out of 10000 (max. 10000000)"#, + }; + + assert_debug_snapshot!(parse(&log).errors); + } } diff --git a/support/texlab/src/syntax/latex/kind.rs b/support/texlab/src/syntax/latex/kind.rs index fcab393380..90b68145a7 100644 --- a/support/texlab/src/syntax/latex/kind.rs +++ b/support/texlab/src/syntax/latex/kind.rs @@ -13,7 +13,6 @@ pub enum SyntaxKind { R_BRACK, L_PAREN, R_PAREN, - PARAMETER, COMMA, EQUALITY_SIGN, WORD, diff --git a/support/texlab/src/syntax/latex/lexer.rs b/support/texlab/src/syntax/latex/lexer.rs index 7cd94ec897..f697403577 100644 --- a/support/texlab/src/syntax/latex/lexer.rs +++ b/support/texlab/src/syntax/latex/lexer.rs @@ -30,16 +30,13 @@ enum Token { #[token(")")] R_PAREN, - #[regex(r"#\d?")] - PARAMETER, - #[token(",")] COMMA, #[token("=")] EQUALITY_SIGN, - #[regex(r"[^\s\\%\{\},\$\[\]\(\)=\#]+")] + #[regex(r"[^\s\\%\{\},\$\[\]\(\)=]+")] #[error] WORD, diff --git a/support/texlab/src/syntax/latex/parser.rs b/support/texlab/src/syntax/latex/parser.rs index a21674f51d..a7fe3342f8 100644 --- a/support/texlab/src/syntax/latex/parser.rs +++ b/support/texlab/src/syntax/latex/parser.rs @@ -105,7 +105,6 @@ impl<'a> Parser<'a> { self.eat(); self.builder.finish_node(); } - PARAMETER => self.eat(), WORD | COMMA => self.text(context), EQUALITY_SIGN => self.eat(), DOLLAR => self.formula(), @@ -212,10 +211,6 @@ impl<'a> Parser<'a> { Some(WORD) => { self.key(); } - Some(PARAMETER) => { - self.eat(); - self.trivia(); - } Some(_) | None => { self.builder.token(MISSING.into(), ""); } @@ -230,7 +225,7 @@ impl<'a> Parser<'a> { while self .peek() - .filter(|&kind| matches!(kind, WHITESPACE | COMMENT | WORD | COMMA | PARAMETER)) + .filter(|&kind| matches!(kind, WHITESPACE | COMMENT | WORD | COMMA)) .is_some() { if self.peek() == Some(WORD) { @@ -253,10 +248,6 @@ impl<'a> Parser<'a> { self.eat(); self.trivia(); } - Some(PARAMETER) => { - self.eat(); - self.trivia(); - } Some(_) | None => { self.builder.token(MISSING.into(), ""); } @@ -301,10 +292,6 @@ impl<'a> Parser<'a> { Some(WORD) => { self.key(); } - Some(PARAMETER) => { - self.eat(); - self.trivia(); - } Some(_) | None => { self.builder.token(MISSING.into(), ""); } @@ -1543,6 +1530,11 @@ mod tests { assert_debug_snapshot!(setup(r#"\ref{foo, bar}"#)); } + #[test] + fn test_label_reference_incomplete() { + assert_debug_snapshot!(setup(r#"Equation \eqref{eq is a \emph{useful} identity."#)); + } + #[test] fn test_equation_label_reference_simple() { assert_debug_snapshot!(setup(r#"\eqref{foo}"#)); diff --git a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__lexer__tests__command_with_parameter.snap b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__lexer__tests__command_with_parameter.snap index 9cff735e99..a9a0e11ad7 100644 --- a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__lexer__tests__command_with_parameter.snap +++ b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__lexer__tests__command_with_parameter.snap @@ -37,7 +37,7 @@ expression: "verify(r#\"\\newcommand{\\id}[1]{#1}\"#)" "{", ), ( - PARAMETER, + WORD, "#1", ), ( diff --git a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__lexer__tests__invalid_parameter.snap b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__lexer__tests__invalid_parameter.snap index adadfcf0ef..e947ec3fb6 100644 --- a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__lexer__tests__invalid_parameter.snap +++ b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__lexer__tests__invalid_parameter.snap @@ -5,7 +5,7 @@ expression: "verify(r#\"#\"#)" --- [ ( - PARAMETER, + WORD, "#", ), ] diff --git a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__command_definition_simple.snap b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__command_definition_simple.snap index b0d9b225d0..b6b8380155 100644 --- a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__command_definition_simple.snap +++ b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__command_definition_simple.snap @@ -20,6 +20,7 @@ ROOT@0..23 R_CURLY@18..19 "}" CURLY_GROUP@19..23 L_CURLY@19..20 "{" - PARAMETER@20..22 "#1" + TEXT@20..22 + WORD@20..22 "#1" R_CURLY@22..23 "}" diff --git a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__label_reference_incomplete.snap b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__label_reference_incomplete.snap new file mode 100644 index 0000000000..047eea657d --- /dev/null +++ b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__label_reference_incomplete.snap @@ -0,0 +1,33 @@ +--- +source: src/syntax/latex/parser.rs +expression: "setup(r#\"Equation \\eqref{eq is a \\emph{useful} identity.\"#)" + +--- +ROOT@0..47 + PREAMBLE@0..47 + TEXT@0..9 + WORD@0..8 "Equation" + WHITESPACE@8..9 " " + LABEL_REFERENCE@9..24 + LABEL_REFERENCE_NAME@9..15 "\\eqref" + CURLY_GROUP_WORD_LIST@15..24 + L_CURLY@15..16 "{" + KEY@16..24 + WORD@16..18 "eq" + WHITESPACE@18..19 " " + WORD@19..21 "is" + WHITESPACE@21..22 " " + WORD@22..23 "a" + WHITESPACE@23..24 " " + MISSING@24..24 "" + GENERIC_COMMAND@24..38 + GENERIC_COMMAND_NAME@24..29 "\\emph" + CURLY_GROUP@29..38 + L_CURLY@29..30 "{" + TEXT@30..36 + WORD@30..36 "useful" + R_CURLY@36..37 "}" + WHITESPACE@37..38 " " + TEXT@38..47 + WORD@38..47 "identity." + diff --git a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__parameter.snap b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__parameter.snap index 8c6bd90cb8..4888672c31 100644 --- a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__parameter.snap +++ b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__parameter.snap @@ -5,5 +5,6 @@ expression: "setup(r#\"#1\"#)" --- ROOT@0..2 PREAMBLE@0..2 - PARAMETER@0..2 "#1" + TEXT@0..2 + WORD@0..2 "#1" diff --git a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__parameter_error.snap b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__parameter_error.snap index 1a9b68fa2d..843327ab80 100644 --- a/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__parameter_error.snap +++ b/support/texlab/src/syntax/latex/snapshots/texlab__syntax__latex__parser__tests__parameter_error.snap @@ -5,5 +5,6 @@ expression: "setup(r#\"#\"#)" --- ROOT@0..1 PREAMBLE@0..1 - PARAMETER@0..1 "#" + TEXT@0..1 + WORD@0..1 "#" diff --git a/support/texlab/src/syntax/snapshots/texlab__syntax__build_log__tests__parse_007.snap b/support/texlab/src/syntax/snapshots/texlab__syntax__build_log__tests__parse_007.snap new file mode 100644 index 0000000000..09d99c4f21 --- /dev/null +++ b/support/texlab/src/syntax/snapshots/texlab__syntax__build_log__tests__parse_007.snap @@ -0,0 +1,15 @@ +--- +source: src/syntax/build_log.rs +expression: parse(&log).errors + +--- +[ + BuildError { + relative_path: "/some/folder/a.tex", + level: Error, + message: "Undefined control sequence.", + line: Some( + 3, + ), + }, +] diff --git a/support/texlab/src/workspace/api.rs b/support/texlab/src/workspace/api.rs index 38fa0ce530..1ccd19d4e4 100644 --- a/support/texlab/src/workspace/api.rs +++ b/support/texlab/src/workspace/api.rs @@ -33,7 +33,7 @@ pub trait Workspace: Send + Sync { fn reload(&self, path: PathBuf) -> Result>> { let uri = Arc::new(Uri::from_file_path(path.clone()).unwrap()); - if self.is_open(&uri) { + if self.is_open(&uri) && !uri.as_str().ends_with(".log") { return Ok(self.get(&uri)); } diff --git a/support/texlab/tests/integration/completion.rs b/support/texlab/tests/integration/completion.rs index 01c9824eeb..74e8269d67 100644 --- a/support/texlab/tests/integration/completion.rs +++ b/support/texlab/tests/integration/completion.rs @@ -268,7 +268,7 @@ mod latex { "bibtex", false, )?; - assert_json_snapshot!(complete_and_resolve(&server, tex_uri, 3, 6)?); + assert_json_snapshot!(complete_and_resolve(&server, tex_uri, 3, 7)?); Ok(()) } @@ -549,7 +549,7 @@ mod latex { "latex", false, )?; - assert_json_snapshot!(complete_and_resolve(&server, uri, 5, 5)?); + assert_json_snapshot!(complete_and_resolve(&server, uri, 5, 6)?); Ok(()) } @@ -732,7 +732,7 @@ mod latex { "latex", false, )?; - assert_json_snapshot!(complete_and_resolve(&server, uri, 3, 7)?); + assert_json_snapshot!(complete_and_resolve(&server, uri, 3, 8)?); Ok(()) } @@ -790,7 +790,7 @@ mod latex { "latex", false, )?; - assert_json_snapshot!(complete_and_resolve(&server, uri, 4, 7)?); + assert_json_snapshot!(complete_and_resolve(&server, uri, 4, 8)?); Ok(()) } } diff --git a/support/texlab/tests/integration/issues.rs b/support/texlab/tests/integration/issues.rs index 5d6caeb79d..b991d185d3 100644 --- a/support/texlab/tests/integration/issues.rs +++ b/support/texlab/tests/integration/issues.rs @@ -39,3 +39,23 @@ fn test_408_parent_expansion() -> Result<()> { Ok(()) } + +#[test] +#[cfg(feature = "completion")] +fn test_510_completion_with_unmatched_braces() -> Result<()> { + use insta::assert_debug_snapshot; + + let server = ServerTester::launch_new_instance()?; + server.initialize(ClientCapabilities::default(), None)?; + + let uri = server.open( + "main.tex", + "\\label{eq:foo}\n\\ref{eq is a \\emph{useful} identity.", + "latex", + false, + )?; + + assert_debug_snapshot!(server.complete(uri, 1, 7)?); + + Ok(()) +} diff --git a/support/texlab/tests/integration/snapshots/integration__issues__510_completion_with_unmatched_braces.snap b/support/texlab/tests/integration/snapshots/integration__issues__510_completion_with_unmatched_braces.snap new file mode 100644 index 0000000000..e421d6615e --- /dev/null +++ b/support/texlab/tests/integration/snapshots/integration__issues__510_completion_with_unmatched_braces.snap @@ -0,0 +1,57 @@ +--- +source: tests/integration/issues.rs +expression: "server.complete(uri, 1, 7)?" + +--- +CompletionList { + is_incomplete: false, + items: [ + CompletionItem { + label: "eq:foo", + kind: Some( + Text, + ), + detail: None, + documentation: None, + deprecated: None, + preselect: Some( + false, + ), + sort_text: Some( + "00 eq:foo", + ), + filter_text: Some( + "eq:foo", + ), + insert_text: None, + insert_text_format: None, + insert_text_mode: None, + text_edit: Some( + Edit( + TextEdit { + range: Range { + start: Position { + line: 1, + character: 5, + }, + end: Position { + line: 1, + character: 7, + }, + }, + new_text: "eq:foo", + }, + ), + ), + additional_text_edits: None, + command: None, + commit_characters: None, + data: Some( + String( + "label", + ), + ), + tags: None, + }, + ], +} diff --git a/support/texlab/texlab.pdf b/support/texlab/texlab.pdf index 27f915c944..289c5f1951 100644 Binary files a/support/texlab/texlab.pdf and b/support/texlab/texlab.pdf differ -- cgit v1.2.3