diff options
author | Norbert Preining <norbert@preining.info> | 2021-11-11 03:00:56 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2021-11-11 03:00:56 +0000 |
commit | 5749e1b65a86cb035a8e4809e7383a98619b0984 (patch) | |
tree | 7f699c2ae9ef2ae3f063583650a343e0d37f66da /support/texlab/src | |
parent | 3b9a500a47854adcb6f2a248722ae2225d6d7d43 (diff) |
CTAN sync 202111110300
Diffstat (limited to 'support/texlab/src')
15 files changed, 279 insertions, 33 deletions
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<CompletionParams>, items: &mut Vec<InternalComp } Cursor::Latex(token) if token.kind() == latex::WORD => { 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<P: HasPosition> CursorContext<P> { 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(), ""); } @@ -1544,6 +1531,11 @@ mod tests { } #[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<Option<Arc<Document>>> { 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)); } |