diff options
author | Norbert Preining <norbert@preining.info> | 2023-05-21 03:01:40 +0000 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2023-05-21 03:01:40 +0000 |
commit | acbf029eb7f81c05b715461ab1ce2ab7e4f6ce09 (patch) | |
tree | 1b2e5899af7b651ddc4cb4ff54c08b182cd344e7 /support | |
parent | 9cdcfcf8d9333b1d9b34b61ddc21910bbcc04491 (diff) |
CTAN sync 202305210301
Diffstat (limited to 'support')
30 files changed, 482 insertions, 230 deletions
diff --git a/support/latexindent/LatexIndent/Document.pm b/support/latexindent/LatexIndent/Document.pm index 16a01bf209..59188a7234 100644 --- a/support/latexindent/LatexIndent/Document.pm +++ b/support/latexindent/LatexIndent/Document.pm @@ -187,12 +187,12 @@ sub operate_on_file { $self->remove_leading_space; $self->process_body_of_text; ${$self}{body} =~ s/\r\n/\n/sg if $mainSettings{dos2unixlinebreaks}; - $self->remove_trailing_whitespace( when => "after" ); $self->condense_blank_lines if ( $is_m_switch_active and ${ $mainSettings{modifyLineBreaks} }{condenseMultipleBlankLinesInto} ); $self->unprotect_blank_lines if ( $is_m_switch_active and ${ $mainSettings{modifyLineBreaks} }{preserveBlankLines} ); $self->un_dodge_double_backslash; + $self->remove_trailing_whitespace( when => "after" ); $self->make_replacements( when => "after" ) if $is_rv_switch_active; $self->put_verbatim_back_in( match => "everything-except-commands" ); $self->put_trailing_comments_back_in; diff --git a/support/latexindent/LatexIndent/GetYamlSettings.pm b/support/latexindent/LatexIndent/GetYamlSettings.pm index c46d0c5164..6b97e61737 100644 --- a/support/latexindent/LatexIndent/GetYamlSettings.pm +++ b/support/latexindent/LatexIndent/GetYamlSettings.pm @@ -26,7 +26,7 @@ use Cwd; use Exporter qw/import/; use LatexIndent::LogFile qw/$logger/; our @EXPORT_OK - = qw/yaml_read_settings yaml_modify_line_breaks_settings yaml_get_indentation_settings_for_this_object yaml_poly_switch_get_every_or_custom_value yaml_get_indentation_information yaml_get_object_attribute_for_indentation_settings yaml_alignment_at_ampersand_settings %mainSettings/; + = qw/yaml_read_settings yaml_modify_line_breaks_settings yaml_get_indentation_settings_for_this_object yaml_poly_switch_get_every_or_custom_value yaml_get_indentation_information yaml_get_object_attribute_for_indentation_settings yaml_alignment_at_ampersand_settings %mainSettings %previouslyFoundSettings/; # Read in defaultSettings.YAML file our $defaultSettings; @@ -818,6 +818,14 @@ sub yaml_get_indentation_settings_for_this_object { columns => ${$self}{columns}, ); + # text wrap 'after' information + if ( $is_m_switch_active + and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' + and defined ${$self}{indentRule} ) + { + ${ ${previouslyFoundSettings}{textWrapAfter} }{$name} = $indentation; + } + # don't forget alignment settings! foreach (@alignAtAmpersandInformation) { ${ ${previouslyFoundSettings}{$storageName} }{ ${$_}{name} } = ${$self}{ ${$_}{name} } @@ -1091,11 +1099,27 @@ sub yaml_get_indentation_information { if ( defined $indentationInformation ) { if ( $indentationAbout eq "noAdditionalIndent" and $indentationInformation == 1 ) { $logger->trace("Found! Using '' (see $indentationAbout)") if $is_t_switch_active; + + # text wrapping 'after' requires knowledge of indent rules + # + if ( $is_m_switch_active + and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' ) + { + ${$self}{indentRule} = $indentationInformation; + } return q(); } elsif ( $indentationAbout eq "indentRules" and $indentationInformation =~ m/^\h*$/ ) { $logger->trace("Found! Using '$indentationInformation' (see $indentationAbout)") if $is_t_switch_active; + + # text wrapping 'after' requires knowledge of indent rules + # + if ( $is_m_switch_active + and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' ) + { + ${$self}{indentRule} = $indentationInformation; + } return $indentationInformation; } } @@ -1115,12 +1139,28 @@ sub yaml_get_indentation_information { { $logger->trace("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active; + + # text wrapping 'after' requires knowledge of indent rules + # + if ( $is_m_switch_active + and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' ) + { + ${$self}{indentRule} = $indentationInformation; + } return q(); } elsif ( $globalInformation eq "indentRulesGlobal" ) { if ( ${ $mainSettings{$globalInformation} }{$YamlName} =~ m/^\h*$/ ) { $logger->trace("$globalInformation specified for $YamlName (see $globalInformation)") if $is_t_switch_active; + + # text wrapping 'after' requires knowledge of indent rules + # + if ( $is_m_switch_active + and ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' ) + { + ${$self}{indentRule} = $indentationInformation; + } return ${ $mainSettings{$globalInformation} }{$YamlName}; } elsif ( ${ $mainSettings{$globalInformation} }{$YamlName} ne '0' ) { diff --git a/support/latexindent/LatexIndent/Version.pm b/support/latexindent/LatexIndent/Version.pm index c20ea7afb1..59ed17e3e0 100644 --- a/support/latexindent/LatexIndent/Version.pm +++ b/support/latexindent/LatexIndent/Version.pm @@ -20,6 +20,6 @@ use warnings; use Exporter qw/import/; our @EXPORT_OK = qw/$versionNumber $versionDate/; -our $versionNumber = '3.21'; -our $versionDate = '2023-05-01'; +our $versionNumber = '3.21.1'; +our $versionDate = '2023-05-20'; 1 diff --git a/support/latexindent/LatexIndent/Wrap.pm b/support/latexindent/LatexIndent/Wrap.pm index 9185459dae..dc99170452 100644 --- a/support/latexindent/LatexIndent/Wrap.pm +++ b/support/latexindent/LatexIndent/Wrap.pm @@ -21,7 +21,7 @@ use Text::Wrap; use LatexIndent::Tokens qw/%tokens/; use LatexIndent::AlignmentAtAmpersand qw/get_column_width/; use LatexIndent::TrailingComments qw/$trailingCommentRegExp @trailingComments/; -use LatexIndent::GetYamlSettings qw/%mainSettings/; +use LatexIndent::GetYamlSettings qw/%mainSettings %previouslyFoundSettings/; use LatexIndent::Switches qw/$is_t_switch_active $is_tt_switch_active $is_m_switch_active/; use LatexIndent::LogFile qw/$logger/; use LatexIndent::Verbatim qw/%verbatimStorage/; @@ -207,7 +207,7 @@ sub text_wrap { # store the text wrap blocks my @textWrapBlockStorage = split( /($blocksFollow)/, ${$self}{body} ); - @textWrapBlockStorage = split( /(\s*$blocksFollow)/, ${$self}{body} ) + @textWrapBlockStorage = split( /(\s*$blocksFollow+)/, ${$self}{body} ) if ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after'; # sentences need special treatment @@ -273,6 +273,7 @@ sub text_wrap { # # see also: test-cases/text-wrap/issue-359*.tex # + my $firstLineColumns = 0; if ( ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{when} eq 'after' ) { # reset columns @@ -288,7 +289,7 @@ sub text_wrap { my $thingToMeasure = ( split( /\R/, ${$self}{follows} ) )[-1]; $subsequentSpace - = ( ${$self}{follows} ? " " x length($thingToMeasure) : q() ); + = ( ${$self}{follows} ? " " x &get_column_width($thingToMeasure) : q() ); # possible tab adjustments $thingToMeasure = q() if ( not defined $thingToMeasure ); @@ -329,7 +330,7 @@ sub text_wrap { $subsequentSpace = ( $textWrapBlockCount == 0 ? q() - : " " x length($thingToMeasure) + : " " x &get_column_width($thingToMeasure) ); # possible tab adjustments @@ -337,8 +338,45 @@ sub text_wrap { for ( my $i = 1; $i <= $numberOfTABS; $i++ ) { $subsequentSpace =~ s/ / /; } + + # check for custom indentRules see + # + # test-cases/text-wrap/issue-444.tex and friends + # + # https://github.com/cmhughes/latexindent.pl/issues/444 + # + # WARNING: this routine isn't perfect, it's *VERY DIFFICULT* + # to figure out what a code block is without actually + # finding the code block + # + # **known issue** with textWrap: after and indentRules + # + # the below will likely need to be built upon + # + my $name = $thingToMeasure; + $name =~ s/\\begin//sg; + $name =~ s/[^a-zA-Z\@0-9]//sg; + + # check that $name is within indentRules + if ( $textWrapBlockCount > 0 + and $name !~ m/^\h*$/ + and defined $previouslyFoundSettings{textWrapAfter} + and defined ${ $previouslyFoundSettings{textWrapAfter} }{$name} + and ${ $previouslyFoundSettings{textWrapAfter} }{$name} =~ m/^\h*$/ ) + { + + $firstLineColumns = $columns - length($subsequentSpace); + + $thingToMeasure =~ s/^\h*//; + for ( my $i = 0; $i < &get_column_width($thingToMeasure); $i++ ) { + $subsequentSpace =~ s/ //; + } + $subsequentSpace .= ${ $previouslyFoundSettings{textWrapAfter} }{$name}; + } + } } + $Text::Wrap::columns = $columns - length($subsequentSpace); # possible tab adjustments @@ -470,8 +508,37 @@ sub text_wrap { } # perform the text wrap routine - $textWrapBlockStorageValue = wrap( '', '', $textWrapBlockStorageValue ) - if ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{columns} > 0; + if ( $firstLineColumns > 0 ) { + + # when 'after' is active, and indentation rules specified, they need attention + # + # noAdditionalIndent *per-name* basis + # indentRules *per-name* basis + # noAdditionalIndentGlobal + # indentRulesGlobal + # + # see + # + # test-cases/text-wrap/issue-444.tex + # + my $secondLineOnwardsColumns = $Text::Wrap::columns; + + # wrap the *first* line + $Text::Wrap::columns = $firstLineColumns; + $textWrapBlockStorageValue = wrap( '', '', $textWrapBlockStorageValue ); + my @tmpBlock = split( /\R/, $textWrapBlockStorageValue ); + my $firstLine = shift(@tmpBlock); + + # wrap the *subsequent* lines + my $secondLineOnwards = join( " ", @tmpBlock ); + $Text::Wrap::columns = $secondLineOnwardsColumns; + $secondLineOnwards = wrap( '', '', $secondLineOnwards ); + $textWrapBlockStorageValue = $firstLine . "\n" . $secondLineOnwards; + } + else { + $textWrapBlockStorageValue = wrap( '', '', $textWrapBlockStorageValue ) + if ${ $mainSettings{modifyLineBreaks}{textWrapOptions} }{columns} > 0; + } # if text wrap has happened *AFTER* indentation, # then we need to add the leading indentation diff --git a/support/latexindent/README b/support/latexindent/README index c799fc2b29..88398cdba9 100644 --- a/support/latexindent/README +++ b/support/latexindent/README @@ -1,5 +1,5 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - latexindent.pl, version 3.21, 2023-05-01 + latexindent.pl, version 3.21.1, 2023-05-20 PERL script to indent code within environments, and align delimited environments in .tex files. diff --git a/support/latexindent/bin/linux/latexindent b/support/latexindent/bin/linux/latexindent Binary files differindex d03ceb16b8..449615d057 100644 --- a/support/latexindent/bin/linux/latexindent +++ b/support/latexindent/bin/linux/latexindent diff --git a/support/latexindent/bin/macos/latexindent b/support/latexindent/bin/macos/latexindent Binary files differindex a86d4d43c3..c77592e6f6 100644 --- a/support/latexindent/bin/macos/latexindent +++ b/support/latexindent/bin/macos/latexindent diff --git a/support/latexindent/defaultSettings.yaml b/support/latexindent/defaultSettings.yaml index 698ef09c11..a3582b934b 100644 --- a/support/latexindent/defaultSettings.yaml +++ b/support/latexindent/defaultSettings.yaml @@ -1,5 +1,5 @@ # -# latexindent.pl, version 3.21, 2023-05-01 +# latexindent.pl, version 3.21.1, 2023-05-20 # # defaultSettings.yaml, the default settings for latexindent.pl # diff --git a/support/latexindent/documentation/latexindent-yaml-schema.json b/support/latexindent/documentation/latexindent-yaml-schema.json index b29664e2c0..4084168a8b 100644 --- a/support/latexindent/documentation/latexindent-yaml-schema.json +++ b/support/latexindent/documentation/latexindent-yaml-schema.json @@ -2,7 +2,7 @@ "$schema": "http://json-schema.org/schema", "$id": "latexindent-yaml-schema.json", "title": "latexindent.pl YAML schema", - "description": "latexindent.pl YAML schema helper, V3.21 2023-05-01", + "description": "latexindent.pl YAML schema helper, V3.21.1 2023-05-20", "type": "object", "properties": { "fileExtensionPreference": { diff --git a/support/latexindent/documentation/latexindent.pdf b/support/latexindent/documentation/latexindent.pdf Binary files differindex dfdeea52cc..a853ce27c9 100644 --- a/support/latexindent/documentation/latexindent.pdf +++ b/support/latexindent/documentation/latexindent.pdf diff --git a/support/latexindent/documentation/latexindent.tex b/support/latexindent/documentation/latexindent.tex index a85bdfafae..618b49cad1 100644 --- a/support/latexindent/documentation/latexindent.tex +++ b/support/latexindent/documentation/latexindent.tex @@ -4315,7 +4315,7 @@ latexindent.pl headings2.tex -l headings4.yaml \end{example} \paragraph{namedGroupingBracesBrackets} This type of code block is mostly motivated by - tikz-based code; we define this code block as follows: + tikz-based code; we define this code block as follows: \begin{itemize} \item it must immediately follow either \emph{horizontal space} OR \emph{one or more line breaks} OR \lstinline!{! OR \lstinline![! OR \lstinline!$! OR \lstinline!)! @@ -4351,8 +4351,9 @@ latexindent.pl headings2.tex -l headings4.yaml \end{itemize} \end{example} - \paragraph{UnNamedGroupingBracesBrackets} occur in a variety of situations; specifically, - we define this type of code block as satisfying the following criteria: + \paragraph{UnNamedGroupingBracesBrackets} occur in a variety of situations; + specifically, we define this type of code block as satisfying the following + criteria: \begin{itemize} \item it must immediately follow either \lstinline!{! OR \lstinline![! OR \lstinline!,! OR \lstinline!&! OR \lstinline!)! OR \lstinline!(! OR @@ -4391,7 +4392,7 @@ latexindent.pl headings2.tex -l headings4.yaml \texttt{always-un-named}. \paragraph{filecontents} code blocks behave just as \texttt{environments}, except that - neither arguments nor items are sought. + neither arguments nor items are sought. \subsubsection{Summary} \index{indentation!summary} @@ -8260,6 +8261,10 @@ latexindent.pl bib2.bib -l bibsettings1.yaml,bibsettings2.yaml -o=+-mod2 \begin{description} \item[multicolumn alignment] when working with code blocks in which multicolumn commands overlap, the algorithm can fail; see \vref{lst:tabular2-mod2}. + \item[textWrap after] when operating with \texttt{indentRules} (see + \vref{sec:noadd-indent-rules}) may not always cooperate with one another; if you + have a specific example that does not work, please report it to + \cite{latexindent-home}. \item[efficiency] particularly when the \texttt{-m} switch is active, as this adds many checks and processes. The current implementation relies upon finding and storing \emph{every} code block (see the discussion on \cpageref{page:phases}); I hope diff --git a/support/latexindent/latexindent.pl b/support/latexindent/latexindent.pl index e9f37442d2..4b8e2b7527 100755 --- a/support/latexindent/latexindent.pl +++ b/support/latexindent/latexindent.pl @@ -1,5 +1,5 @@ #!/usr/bin/env perl -# latexindent.pl, version 3.21, 2023-05-01 +# latexindent.pl, version 3.21.1, 2023-05-20 # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by diff --git a/support/texlab/CHANGELOG.md b/support/texlab/CHANGELOG.md index 01d9a9ca33..b165ced68e 100644 --- a/support/texlab/CHANGELOG.md +++ b/support/texlab/CHANGELOG.md @@ -5,6 +5,17 @@ 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). +## [5.6.0] - 2023-05-20 + +### Added + +- Add `texlab.cancelBuild` command to cancel the currently active build ([#887](https://github.com/latex-lsp/texlab/issues/887)) + +### Fixed + +- Fix resolving include commands from the `import` package ([#885](https://github.com/latex-lsp/texlab/issues/885)) +- Fix regression when tracking active cursor position ([#880](https://github.com/latex-lsp/texlab/issues/880)) + ## [5.5.1] - 2023-05-06 ### Fixed diff --git a/support/texlab/Cargo.lock b/support/texlab/Cargo.lock index d24072ed41..aceaaf083a 100644 --- a/support/texlab/Cargo.lock +++ b/support/texlab/Cargo.lock @@ -18,6 +18,15 @@ dependencies = [ ] [[package]] +name = "aho-corasick" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "67fc08ce920c31afb70f013dcce1bfc3a3195de6a228474e45e1f145b36f8d04" +dependencies = [ + "memchr", +] + +[[package]] name = "anes" version = "0.1.6" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -34,9 +43,9 @@ dependencies = [ [[package]] name = "anstream" -version = "0.3.0" +version = "0.3.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9e579a7752471abc2a8268df8b20005e3eadd975f585398f17efcfd8d4927371" +checksum = "0ca84f3628370c59db74ee214b3263d58f9aadd9b4fe7e711fd87dc452b7f163" dependencies = [ "anstyle", "anstyle-parse", @@ -73,9 +82,9 @@ dependencies = [ [[package]] name = "anstyle-wincon" -version = "1.0.0" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4bcd8291a340dd8ac70e18878bc4501dd7b4ff970cfa21c207d36ece51ea88fd" +checksum = "180abfa45703aebe0093f79badacc01b8fd4ea2e35118747e5811127f926e188" dependencies = [ "anstyle", "windows-sys 0.48.0", @@ -83,9 +92,9 @@ dependencies = [ [[package]] name = "anyhow" -version = "1.0.70" +version = "1.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7de8ce5e0f9f8d88245311066a578d72b7af3e7088f32783804676302df237e4" +checksum = "9c7d0618f0e0b7e8ff11427422b64564d5fb0be1940354bfe2e0529b18a9d9b8" [[package]] name = "assert_unordered" @@ -168,9 +177,9 @@ dependencies = [ [[package]] name = "bumpalo" -version = "3.12.0" +version = "3.12.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0d261e256854913907f67ed06efbc3338dfe6179796deefc1ff763fc1aee5535" +checksum = "3c6ed94e98ecff0c12dd1b04c15ec0d7d9458ca8fe806cea6f12954efe74c63b" [[package]] name = "cast" @@ -202,9 +211,9 @@ dependencies = [ [[package]] name = "ciborium" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b0c137568cc60b904a7724001b35ce2630fd00d5d84805fbb608ab89509d788f" +checksum = "effd91f6c78e5a4ace8a5d3c0b6bfaec9e2baaef55f3efc00e45fb2e477ee926" dependencies = [ "ciborium-io", "ciborium-ll", @@ -213,15 +222,15 @@ dependencies = [ [[package]] name = "ciborium-io" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "346de753af073cc87b52b2083a506b38ac176a44cfb05497b622e27be899b369" +checksum = "cdf919175532b369853f5d5e20b26b43112613fd6fe7aee757e35f7a44642656" [[package]] name = "ciborium-ll" -version = "0.2.0" +version = "0.2.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "213030a2b5a4e0c0892b6652260cf6ccac84827b83a85a534e178e3906c4cf1b" +checksum = "defaa24ecc093c77630e6c15e17c51f5e187bf35ee514f4e2d67baaa96dae22b" dependencies = [ "ciborium-io", "half", @@ -247,9 +256,9 @@ dependencies = [ [[package]] name = "clap" -version = "3.2.23" +version = "3.2.25" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "71655c45cb9845d3270c9d6df84ebe72b4dad3c2ba3f7023ad47c144e4e473a5" +checksum = "4ea181bf566f71cb9a5d17a59e1871af638180a18fb0035c92ae62b705207123" dependencies = [ "bitflags", "clap_lex 0.2.4", @@ -259,9 +268,9 @@ dependencies = [ [[package]] name = "clap" -version = "4.2.2" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b802d85aaf3a1cdb02b224ba472ebdea62014fccfcb269b95a4d76443b5ee5a" +checksum = "93aae7a4192245f70fe75dd9157fc7b4a5bf53e88d30bd4396f7d8f9284d5acc" dependencies = [ "clap_builder", "clap_derive", @@ -270,27 +279,27 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.2.2" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "14a1a858f532119338887a4b8e1af9c60de8249cd7bafd68036a489e261e37b6" +checksum = "4f423e341edefb78c9caba2d9c7f7687d0e72e89df3ce3394554754393ac3990" dependencies = [ "anstream", "anstyle", "bitflags", - "clap_lex 0.4.1", + "clap_lex 0.5.0", "strsim", ] [[package]] name = "clap_derive" -version = "4.2.0" +version = "4.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3f9644cd56d6b87dbe899ef8b053e331c0637664e9e21a33dfcdc36093f5c5c4" +checksum = "191d9573962933b4027f932c600cd252ce27a8ad5979418fe78e43c07996f27b" dependencies = [ "heck", "proc-macro2", "quote", - "syn 2.0.13", + "syn", ] [[package]] @@ -304,9 +313,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.4.1" +version = "0.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8a2dd5a6fe8c6e3502f568a6353e5273bbb15193ad9a89e457b9970798efbea1" +checksum = "2da6da31387c7e4ef160ffab6d5e7f00c42626fe39aea70a7b0f1773f7dd6c1b" [[package]] name = "colorchoice" @@ -323,6 +332,7 @@ dependencies = [ "bstr", "crossbeam-channel", "itertools", + "libc", "log", "rowan", "rustc-hash", @@ -333,14 +343,14 @@ dependencies = [ [[package]] name = "console" -version = "0.15.5" +version = "0.15.6" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c3d79fbe8970a77e3e34151cc13d3b3e248aa0faaecb9f6091fa07ebefe5ad60" +checksum = "d0525278dce688103060006713371cedbad27186c7d913f33d866b498da0f595" dependencies = [ "encode_unicode", "lazy_static", "libc", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -351,9 +361,9 @@ checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636" [[package]] name = "cpufeatures" -version = "0.2.6" +version = "0.2.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "280a9f2d8b3a38871a3c8a46fb80db65e5e5ed97da80c4d08bf27fb63e35e181" +checksum = "3e4c1eaa2012c47becbbad2ab175484c2a84d1185b566fb2cc5b8707343dfe58" dependencies = [ "libc", ] @@ -377,7 +387,7 @@ dependencies = [ "atty", "cast", "ciborium", - "clap 3.2.23", + "clap 3.2.25", "criterion-plot", "itertools", "lazy_static", @@ -458,9 +468,9 @@ dependencies = [ [[package]] name = "digest" -version = "0.10.6" +version = "0.10.7" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8168378f4e5023e7218c89c891c0fd8ecdb5e5e4f18cb78f38cf245dd021e76f" +checksum = "9ed9a281f7bc9b7576e61468ba615a66a5c8cfdff42420a70aa82701a3b1e292" dependencies = [ "block-buffer", "crypto-common", @@ -468,22 +478,23 @@ dependencies = [ [[package]] name = "dirs" -version = "5.0.0" +version = "5.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dece029acd3353e3a58ac2e3eb3c8d6c35827a892edc6cc4138ef9c33df46ecd" +checksum = "44c45a9d03d6676652bcb5e724c7e988de1acad23a711b5217ab9cbecbec2225" dependencies = [ "dirs-sys", ] [[package]] name = "dirs-sys" -version = "0.4.0" +version = "0.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "04414300db88f70d74c5ff54e50f9e1d1737d9a5b90f53fcf2e95ca2a9ab554b" +checksum = "520f05a5cbd335fae5a99ff7a6ab8627577660ee5cfd6a94a6a929b52ff0321c" dependencies = [ "libc", + "option-ext", "redox_users", - "windows-sys 0.45.0", + "windows-sys 0.48.0", ] [[package]] @@ -577,9 +588,9 @@ dependencies = [ [[package]] name = "flate2" -version = "1.0.25" +version = "1.0.26" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a8a2db397cb1c8772f31494cb8917e48cd1e64f0fa7efac59fbd741a0a8ce841" +checksum = "3b9429470923de8e8cbd4d2dc513535400b4b3fef0319fb5c4e1f520a7bef743" dependencies = [ "crc32fast", "miniz_oxide", @@ -645,7 +656,7 @@ version = "0.4.10" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "029d74589adefde59de1a0c4f4732695c32805624aec7b68d91503d4dba79afc" dependencies = [ - "aho-corasick", + "aho-corasick 0.7.20", "bstr", "fnv", "log", @@ -696,12 +707,11 @@ checksum = "fed44880c466736ef9a5c5b5facefb5ed0785676d0c02d612db14e54f0d84286" [[package]] name = "human_name" -version = "2.0.1" +version = "2.0.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "42af7ece82db04720531abb16506781d40a72c8e62ecb0762d39746d2173255e" +checksum = "71b68533610561604eed4d26b480b5fecfba40514672f961d6669825be847fda" dependencies = [ "crossbeam-utils", - "libc", "phf", "phf_codegen", "serde", @@ -837,9 +847,9 @@ checksum = "72167d68f5fce3b8655487b8038691a3c9984ee769590f93f2a631f4ad64e4f5" [[package]] name = "js-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "445dde2150c55e483f3d8416706b97ec8e8237c307e5b7b4b8dd15e6af2a0730" +checksum = "2f37a4a5928311ac501dee68b3c7613a1037d0edb30c8e5427bd832d55d1b790" dependencies = [ "wasm-bindgen", ] @@ -872,9 +882,9 @@ checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646" [[package]] name = "libc" -version = "0.2.141" +version = "0.2.144" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3304a64d199bb964be99741b7a14d26972741915b3649639149b2479bb46f4b5" +checksum = "2b00cc1c228a6782d0f076e7b232802e0c5689d41bb5df366f2a6b6621cfdfe1" [[package]] name = "linked-hash-map" @@ -884,9 +894,9 @@ checksum = "0717cef1bc8b636c6e1c1bbdefc09e6322da8a9321966e8928ef80d20f7f770f" [[package]] name = "linux-raw-sys" -version = "0.3.1" +version = "0.3.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59d8c75012853d2e872fb56bc8a2e53718e2cafe1a4c823143141c6d90c322f" +checksum = "ef53942eb7bf7ff43a617b3e2c1c4a5ecf5944a7c1bc12d7ee39bbb15e5c1519" [[package]] name = "lock_api" @@ -926,8 +936,8 @@ dependencies = [ "fnv", "proc-macro2", "quote", - "regex-syntax", - "syn 2.0.13", + "regex-syntax 0.6.29", + "syn", ] [[package]] @@ -981,9 +991,9 @@ dependencies = [ [[package]] name = "miniz_oxide" -version = "0.6.2" +version = "0.7.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b275950c28b37e794e8c55d88aeb5e139d0ce23fdbbeda68f8d7174abdf9e8fa" +checksum = "e7810e0be55b428ada41041c41f32c9f1a42817901b4ccf45fa3d4b6561e74c7" dependencies = [ "adler", ] @@ -1002,9 +1012,9 @@ dependencies = [ [[package]] name = "notify" -version = "5.1.0" +version = "5.2.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58ea850aa68a06e48fdb069c0ec44d0d64c8dbffa49bf3b6f7f0a901fdea1ba9" +checksum = "729f63e1ca555a43fe3efa4f3efdf4801c479da85b432242a7b726f353c88486" dependencies = [ "bitflags", "crossbeam-channel", @@ -1015,7 +1025,7 @@ dependencies = [ "libc", "mio", "walkdir", - "windows-sys 0.42.0", + "windows-sys 0.45.0", ] [[package]] @@ -1060,6 +1070,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0ab1bc2a289d34bd04a330323ac98a1b4bc82c9d9fcb1e66b63caa84da26b575" [[package]] +name = "option-ext" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "04744f49eae99ab78e0d5c0b603ab218f515ea8cfe5a456d7629ad883a3b6e7d" + +[[package]] name = "os_str_bytes" version = "6.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1109,9 +1125,9 @@ checksum = "478c572c3d73181ff3c2539045f6eb99e5491218eae919370993b890cdbdd98e" [[package]] name = "pest" -version = "2.5.7" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7b1403e8401ad5dedea73c626b99758535b342502f8d1e361f4a2dd952749122" +checksum = "e68e84bfb01f0507134eac1e9b410a12ba379d064eab48c50ba4ce329a527b70" dependencies = [ "thiserror", "ucd-trie", @@ -1119,9 +1135,9 @@ dependencies = [ [[package]] name = "pest_derive" -version = "2.5.7" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "be99c4c1d2fc2769b1d00239431d711d08f6efedcecb8b6e30707160aee99c15" +checksum = "6b79d4c71c865a25a4322296122e3924d30bc8ee0834c8bfc8b95f7f054afbfb" dependencies = [ "pest", "pest_generator", @@ -1129,22 +1145,22 @@ dependencies = [ [[package]] name = "pest_generator" -version = "2.5.7" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e56094789873daa36164de2e822b3888c6ae4b4f9da555a1103587658c805b1e" +checksum = "6c435bf1076437b851ebc8edc3a18442796b30f1728ffea6262d59bbe28b077e" dependencies = [ "pest", "pest_meta", "proc-macro2", "quote", - "syn 2.0.13", + "syn", ] [[package]] name = "pest_meta" -version = "2.5.7" +version = "2.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6733073c7cff3d8459fda0e42f13a047870242aed8b509fe98000928975f359e" +checksum = "745a452f8eb71e39ffd8ee32b3c5f51d03845f99786fa9b68db6ff509c505411" dependencies = [ "once_cell", "pest", @@ -1219,18 +1235,18 @@ dependencies = [ [[package]] name = "proc-macro2" -version = "1.0.56" +version = "1.0.58" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2b63bdb0cd06f1f4dedf69b254734f9b45af66e4a031e42a7480257d9898b435" +checksum = "fa1fb82fc0c281dd9671101b66b771ebbe1eaf967b96ac8740dcba4b70005ca8" dependencies = [ "unicode-ident", ] [[package]] name = "quote" -version = "1.0.26" +version = "1.0.27" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4424af4bf778aae2051a77b60283332f386554255d722233d09fbfc7e30da2fc" +checksum = "8f4f29d145265ec1c483c7c654450edde0bfe043d3938d6972630663356d9500" dependencies = [ "proc-macro2", ] @@ -1303,13 +1319,13 @@ dependencies = [ [[package]] name = "regex" -version = "1.7.3" +version = "1.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8b1f693b24f6ac912f4893ef08244d70b6067480d2f1a46e950c9691e6749d1d" +checksum = "af83e617f331cc6ae2da5443c602dfa5af81e517212d9d611a5b3ba1777b5370" dependencies = [ - "aho-corasick", + "aho-corasick 1.0.1", "memchr", - "regex-syntax", + "regex-syntax 0.7.1", ] [[package]] @@ -1325,6 +1341,12 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1" [[package]] +name = "regex-syntax" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a5996294f19bd3aae0453a862ad728f60e6600695733dd5df01da90c54363a3c" + +[[package]] name = "rowan" version = "0.15.11" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -1345,9 +1367,9 @@ checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" [[package]] name = "rustix" -version = "0.37.11" +version = "0.37.19" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85597d61f83914ddeba6a47b3b8ffe7365107221c2e557ed94426489fefb5f77" +checksum = "acf8729d8542766f1b2cf77eb034d52f40d375bb8b615d0b147089946e16613d" dependencies = [ "bitflags", "errno", @@ -1380,22 +1402,22 @@ checksum = "d29ab0c6d3fc0ee92fe66e2d99f700eab17a8d57d1c1d3b748380fb20baa78cd" [[package]] name = "serde" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bb2f3770c8bce3bcda7e149193a069a0f4365bda1fa5cd88e03bca26afc1216c" +checksum = "2113ab51b87a539ae008b5c6c02dc020ffa39afd2d83cffcb3f4eb2722cebec2" dependencies = [ "serde_derive", ] [[package]] name = "serde_derive" -version = "1.0.160" +version = "1.0.163" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "291a097c63d8497e00160b166a967a4a79c64f3facdd01cbd7502231688d77df" +checksum = "8c805777e3930c8883389c602315a24224bcc738b63905ef87cd1420353ea93e" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn", ] [[package]] @@ -1427,7 +1449,7 @@ checksum = "bcec881020c684085e55a25f7fd888954d56609ef363479dc5a1305eb0d40cab" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn", ] [[package]] @@ -1501,20 +1523,9 @@ dependencies = [ [[package]] name = "syn" -version = "1.0.109" +version = "2.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" -dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", -] - -[[package]] -name = "syn" -version = "2.0.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c9da457c5285ac1f936ebd076af6dac17a61cfe7826f2076b4d015cf47bc8ec" +checksum = "a6f671d4b5ffdb8eadec19c0ae67fe2639df8684bd7bc4b83d986b8db549cf01" dependencies = [ "proc-macro2", "quote", @@ -1555,13 +1566,13 @@ dependencies = [ [[package]] name = "texlab" -version = "5.5.1" +version = "5.6.0" dependencies = [ "anyhow", "assert_unordered", "base-db", "citeproc", - "clap 4.2.2", + "clap 4.3.0", "commands", "criterion", "crossbeam-channel", @@ -1625,7 +1636,7 @@ checksum = "f9456a42c5b0d803c8cd86e73dd7cc9edd429499f37a3550d286d5e86720569f" dependencies = [ "proc-macro2", "quote", - "syn 2.0.13", + "syn", ] [[package]] @@ -1776,9 +1787,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "31f8dcbc21f30d9b8f2ea926ecb58f6b91192c17e9d33594b3df58b2007ca53b" +checksum = "5bba0e8cb82ba49ff4e229459ff22a191bbe9a1cb3a341610c9c33efc27ddf73" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -1786,24 +1797,24 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "95ce90fd5bcc06af55a641a86428ee4229e44e07033963a2290a8e241607ccb9" +checksum = "19b04bc93f9d6bdee709f6bd2118f57dd6679cf1176a1af464fca3ab0d66d8fb" dependencies = [ "bumpalo", "log", "once_cell", "proc-macro2", "quote", - "syn 1.0.109", + "syn", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-macro" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4c21f77c0bedc37fd5dc21f897894a5ca01e7bb159884559461862ae90c0b4c5" +checksum = "14d6b024f1a526bb0234f52840389927257beb670610081360e5a03c5df9c258" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -1811,28 +1822,28 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2aff81306fcac3c7515ad4e177f521b5c9a15f2b08f4e32d823066102f35a5f6" +checksum = "e128beba882dd1eb6200e1dc92ae6c5dbaa4311aa7bb211ca035779e5efc39f8" dependencies = [ "proc-macro2", "quote", - "syn 1.0.109", + "syn", "wasm-bindgen-backend", "wasm-bindgen-shared", ] [[package]] name = "wasm-bindgen-shared" -version = "0.2.84" +version = "0.2.86" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0046fef7e28c3804e5e38bfa31ea2a0f73905319b677e57ebe37e49358989b5d" +checksum = "ed9d5b4305409d1fc9482fee2d7f9bcbf24b3972bf59817ef757e23982242a93" [[package]] name = "web-sys" -version = "0.3.61" +version = "0.3.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e33b99f4b23ba3eec1a53ac264e35a755f00e966e0065077d6027c0f575b0b97" +checksum = "3bdd9ef4e984da1187bf8110c5cf5b845fbc87a23602cdf912386a76fcd3a7c2" dependencies = [ "js-sys", "wasm-bindgen", @@ -1871,21 +1882,6 @@ checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] name = "windows-sys" -version = "0.42.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a3e1820f08b8513f676f7ab6c1f99ff312fb97b553d30ff4dd86f9f15728aa7" -dependencies = [ - "windows_aarch64_gnullvm 0.42.2", - "windows_aarch64_msvc 0.42.2", - "windows_i686_gnu 0.42.2", - "windows_i686_msvc 0.42.2", - "windows_x86_64_gnu 0.42.2", - "windows_x86_64_gnullvm 0.42.2", - "windows_x86_64_msvc 0.42.2", -] - -[[package]] -name = "windows-sys" version = "0.45.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "75283be5efb2831d37ea142365f009c02ec203cd29a3ebecbc093d52315b66d0" diff --git a/support/texlab/crates/base-db/src/document.rs b/support/texlab/crates/base-db/src/document.rs index cc1a0d44e5..8b6e07fb0f 100644 --- a/support/texlab/crates/base-db/src/document.rs +++ b/support/texlab/crates/base-db/src/document.rs @@ -1,14 +1,13 @@ use std::path::PathBuf; use distro::Language; -use rowan::TextSize; use syntax::{bibtex, latex, BuildError}; use url::Url; use crate::{ diagnostics::{self, Diagnostic}, semantics, - util::LineIndex, + util::{LineCol, LineIndex}, Config, }; @@ -26,7 +25,7 @@ pub struct Document { pub text: String, pub line_index: LineIndex, pub owner: Owner, - pub cursor: TextSize, + pub cursor: LineCol, pub language: Language, pub data: DocumentData, pub diagnostics: Vec<Diagnostic>, @@ -38,7 +37,7 @@ impl Document { text: String, language: Language, owner: Owner, - cursor: TextSize, + cursor: LineCol, config: &Config, ) -> Self { let dir = uri.join(".").unwrap(); diff --git a/support/texlab/crates/base-db/src/semantics/tex.rs b/support/texlab/crates/base-db/src/semantics/tex.rs index 6e238737b0..46c805ba8a 100644 --- a/support/texlab/crates/base-db/src/semantics/tex.rs +++ b/support/texlab/crates/base-db/src/semantics/tex.rs @@ -92,10 +92,12 @@ impl Semantics { } let Some(path) = import.file().and_then(|path| path.key()) else { return }; + let text = format!("{base_dir}{}", path.to_string()); + let range = latex::small_range(&path); self.links.push(Link { kind: LinkKind::Tex, - path: Span::from(&path), + path: Span { text, range }, base_dir: Some(base_dir), }); } diff --git a/support/texlab/crates/base-db/src/workspace.rs b/support/texlab/crates/base-db/src/workspace.rs index 1872c33df1..581d93cfc3 100644 --- a/support/texlab/crates/base-db/src/workspace.rs +++ b/support/texlab/crates/base-db/src/workspace.rs @@ -5,11 +5,12 @@ use std::{ use distro::{Distro, Language}; use itertools::Itertools; -use rowan::{TextRange, TextSize}; +use rowan::TextRange; use rustc_hash::FxHashSet; +use text_size::TextLen; use url::Url; -use crate::{graph, Config, Document, DocumentData, Owner}; +use crate::{graph, util::LineCol, Config, Document, DocumentData, Owner}; #[derive(Debug, Default)] pub struct Workspace { @@ -51,7 +52,7 @@ impl Workspace { text: String, language: Language, owner: Owner, - cursor: TextSize, + cursor: LineCol, ) { log::debug!("Opening document {uri}..."); self.documents.remove(&uri); @@ -74,19 +75,26 @@ impl Workspace { Cow::Owned(text) => text, }; - Ok(self.open(uri, text, language, owner, TextSize::default())) + Ok(self.open(uri, text, language, owner, LineCol { line: 0, col: 0 })) } pub fn edit(&mut self, uri: &Url, delete: TextRange, insert: &str) -> Option<()> { let document = self.lookup(uri)?; let mut text = document.text.clone(); + let cursor = if delete.len() == text.text_len() { + let line = document.cursor.line.min(text.lines().count() as u32); + LineCol { line, col: 0 } + } else { + document.line_index.line_col(delete.start()) + }; + text.replace_range(std::ops::Range::<usize>::from(delete), insert); self.open( document.uri.clone(), text, document.language, Owner::Client, - delete.start(), + cursor, ); Some(()) @@ -184,9 +192,10 @@ impl Workspace { self.folders = folders; } - pub fn set_cursor(&mut self, uri: &Url, cursor: TextSize) -> Option<()> { + pub fn set_cursor(&mut self, uri: &Url, cursor: LineCol) -> Option<()> { let mut document = self.lookup(uri)?.clone(); document.cursor = cursor; + self.documents.remove(&document); self.documents.insert(document); Some(()) } diff --git a/support/texlab/crates/commands/Cargo.toml b/support/texlab/crates/commands/Cargo.toml index ea7358364f..68d034675e 100644 --- a/support/texlab/crates/commands/Cargo.toml +++ b/support/texlab/crates/commands/Cargo.toml @@ -12,6 +12,7 @@ base-db = { path = "../base-db" } bstr = "1.4.0" crossbeam-channel = "0.5.8" itertools = "0.10.5" +libc = "0.2.144" log = "0.4.17" rowan = "0.15.11" rustc-hash = "1.1.0" diff --git a/support/texlab/crates/commands/src/build.rs b/support/texlab/crates/commands/src/build.rs index 3d93601e39..47e156ef72 100644 --- a/support/texlab/crates/commands/src/build.rs +++ b/support/texlab/crates/commands/src/build.rs @@ -1,7 +1,7 @@ use std::{ io::{BufReader, Read}, path::{Path, PathBuf}, - process::{ExitStatus, Stdio}, + process::{Child, Stdio}, thread::{self, JoinHandle}, }; @@ -64,7 +64,7 @@ impl BuildCommand { }) } - pub fn run(self, sender: Sender<String>) -> Result<ExitStatus, BuildError> { + pub fn spawn(self, sender: Sender<String>) -> Result<Child, BuildError> { log::debug!( "Spawning compiler {} {:#?} in directory {}", self.program, @@ -72,19 +72,56 @@ impl BuildCommand { self.working_dir.display() ); - let mut process = std::process::Command::new(&self.program) - .args(self.args) + let mut process = self.spawn_internal()?; + track_output(process.stderr.take().unwrap(), sender.clone()); + track_output(process.stdout.take().unwrap(), sender); + Ok(process) + } + + #[cfg(windows)] + fn spawn_internal(&self) -> Result<Child, BuildError> { + std::process::Command::new(&self.program) + .args(self.args.clone()) .stdin(Stdio::null()) .stdout(Stdio::piped()) .stderr(Stdio::piped()) .current_dir(&self.working_dir) - .spawn()?; + .spawn() + .map_err(Into::into) + } - track_output(process.stderr.take().unwrap(), sender.clone()); - track_output(process.stdout.take().unwrap(), sender); + #[cfg(unix)] + fn spawn_internal(&self) -> Result<Child, BuildError> { + use std::os::unix::process::CommandExt; + std::process::Command::new(&self.program) + .args(self.args.clone()) + .stdin(Stdio::null()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .current_dir(&self.working_dir) + .process_group(0) + .spawn() + .map_err(Into::into) + } + + #[cfg(windows)] + pub fn cancel(pid: u32) -> std::io::Result<bool> { + Ok(std::process::Command::new("taskkill") + .arg("/PID") + .arg(pid.to_string()) + .arg("/F") + .arg("/T") + .status()? + .success()) + } + + #[cfg(not(windows))] + pub fn cancel(pid: u32) -> Result<bool> { + unsafe { + libc::killpg(pid as libc::pid_t, libc::SIGTERM); + } - let status = process.wait(); - Ok(status?) + Ok(true) } } diff --git a/support/texlab/crates/commands/src/fwd_search.rs b/support/texlab/crates/commands/src/fwd_search.rs index c458f33cf1..fc0a130f86 100644 --- a/support/texlab/crates/commands/src/fwd_search.rs +++ b/support/texlab/crates/commands/src/fwd_search.rs @@ -32,6 +32,7 @@ pub enum ForwardSearchError { LaunchViewer(#[from] std::io::Error), } +#[derive(Debug)] pub struct ForwardSearch { program: String, args: Vec<String>, @@ -79,7 +80,7 @@ impl ForwardSearch { let tex_path = tex_path.to_string_lossy().into_owned(); let pdf_path = pdf_path.to_string_lossy().into_owned(); - let line = line.unwrap_or_else(|| child.line_index.line_col(child.cursor).line); + let line = line.unwrap_or_else(|| child.cursor.line); let line = (line + 1).to_string(); let program = config.program.clone(); diff --git a/support/texlab/crates/symbols/src/workspace/sort.rs b/support/texlab/crates/symbols/src/workspace/sort.rs index bc30728da9..0e24c25ac9 100644 --- a/support/texlab/crates/symbols/src/workspace/sort.rs +++ b/support/texlab/crates/symbols/src/workspace/sort.rs @@ -38,9 +38,8 @@ impl<'a> From<&'a Workspace> for ProjectOrdering<'a> { #[cfg(test)] mod tests { - use base_db::Owner; + use base_db::{util::LineCol, Owner}; use distro::Language; - use rowan::TextSize; use super::{ProjectOrdering, Url, Workspace}; @@ -57,7 +56,7 @@ mod tests { String::new(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); workspace.open( @@ -65,7 +64,7 @@ mod tests { String::new(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); workspace.open( @@ -73,7 +72,7 @@ mod tests { r#"\documentclass{article}\include{b}\include{a}"#.to_string(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); let ordering = ProjectOrdering::from(&workspace); @@ -95,7 +94,7 @@ mod tests { String::new(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); workspace.open( @@ -103,7 +102,7 @@ mod tests { r#"\include{a}"#.to_string(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); workspace.open( @@ -111,7 +110,7 @@ mod tests { r#"\begin{documnent}\include{b}\end{document}"#.to_string(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); let ordering = ProjectOrdering::from(&workspace); @@ -132,7 +131,7 @@ mod tests { r#"\begin{document}\include{b}\end{document}"#.to_string(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); workspace.open( @@ -140,7 +139,7 @@ mod tests { r#"\include{a}"#.to_string(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); workspace.open( @@ -148,7 +147,7 @@ mod tests { r#"\include{a}"#.to_string(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); let ordering = ProjectOrdering::from(&workspace); @@ -169,7 +168,7 @@ mod tests { r#"\begin{document}\include{b}\end{document}"#.to_string(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); workspace.open( @@ -177,7 +176,7 @@ mod tests { String::new(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); workspace.open( @@ -185,7 +184,7 @@ mod tests { String::new(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); workspace.open( @@ -193,7 +192,7 @@ mod tests { r#"\begin{document}\include{c}\end{document}"#.to_string(), Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); let ordering = ProjectOrdering::from(&workspace); diff --git a/support/texlab/crates/test-utils/src/fixture.rs b/support/texlab/crates/test-utils/src/fixture.rs index 2935b4f519..1a5071b2db 100644 --- a/support/texlab/crates/test-utils/src/fixture.rs +++ b/support/texlab/crates/test-utils/src/fixture.rs @@ -1,6 +1,6 @@ use std::path::PathBuf; -use base_db::{Owner, Workspace}; +use base_db::{util::LineCol, Owner, Workspace}; use rowan::{TextRange, TextSize}; use url::Url; @@ -35,7 +35,7 @@ impl Fixture { document.text.clone(), language, Owner::Client, - TextSize::from(0), + LineCol { line: 0, col: 0 }, ); } diff --git a/support/texlab/crates/texlab/Cargo.toml b/support/texlab/crates/texlab/Cargo.toml index dc1eb5b913..821ecb9813 100644 --- a/support/texlab/crates/texlab/Cargo.toml +++ b/support/texlab/crates/texlab/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "texlab" description = "LaTeX Language Server" -version = "5.5.1" +version = "5.6.0" license.workspace = true readme = "README.md" authors.workspace = true diff --git a/support/texlab/crates/texlab/benches/bench_main.rs b/support/texlab/crates/texlab/benches/bench_main.rs index 8e69e1e5a4..47b302e313 100644 --- a/support/texlab/crates/texlab/benches/bench_main.rs +++ b/support/texlab/crates/texlab/benches/bench_main.rs @@ -1,9 +1,8 @@ -use base_db::{Owner, Workspace}; +use base_db::{util::LineCol, Owner, Workspace}; use criterion::{black_box, criterion_group, criterion_main, Criterion}; use distro::Language; use lsp_types::{ClientCapabilities, Position, Url}; use parser::{parse_latex, SyntaxConfig}; -use rowan::TextSize; const CODE: &str = include_str!("../../../texlab.tex"); @@ -22,7 +21,7 @@ fn criterion_benchmark(c: &mut Criterion) { text, Language::Tex, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); let client_capabilities = ClientCapabilities::default(); diff --git a/support/texlab/crates/texlab/src/main.rs b/support/texlab/crates/texlab/src/main.rs index ed807f8799..d588a568bc 100644 --- a/support/texlab/crates/texlab/src/main.rs +++ b/support/texlab/crates/texlab/src/main.rs @@ -50,9 +50,6 @@ fn setup_logger(opts: Opts) { let logger = fern::Dispatch::new() .format(|out, message, record| out.finish(format_args!("{} - {}", record.level(), message))) .level(verbosity_level) - .filter(|metadata| { - metadata.target().contains("texlab") || metadata.target().contains("lsp_server") - }) .chain(io::stderr()); let logger = match opts.log_file { diff --git a/support/texlab/crates/texlab/src/server.rs b/support/texlab/crates/texlab/src/server.rs index 6b118655bc..0370f00192 100644 --- a/support/texlab/crates/texlab/src/server.rs +++ b/support/texlab/crates/texlab/src/server.rs @@ -10,15 +10,14 @@ use std::{ }; use anyhow::Result; -use base_db::{Config, Owner, Workspace}; +use base_db::{util::LineCol, Config, Owner, Workspace}; use commands::{BuildCommand, CleanCommand, CleanTarget, ForwardSearch}; use crossbeam_channel::{Receiver, Sender}; use distro::{Distro, Language}; -use itertools::{FoldWhile, Itertools}; use lsp_server::{Connection, ErrorCode, Message, RequestId}; use lsp_types::{notification::*, request::*, *}; use parking_lot::{Mutex, RwLock}; -use rowan::{ast::AstNode, TextSize}; +use rowan::ast::AstNode; use rustc_hash::{FxHashMap, FxHashSet}; use serde::{de::DeserializeOwned, Serialize}; use syntax::bibtex; @@ -67,6 +66,7 @@ pub struct Server { chktex_diagnostics: FxHashMap<Url, Vec<Diagnostic>>, watcher: FileWatcher, pool: ThreadPool, + pending_builds: Arc<Mutex<FxHashSet<u32>>>, } impl Server { @@ -86,6 +86,7 @@ impl Server { chktex_diagnostics: Default::default(), watcher, pool: threadpool::Builder::new().build(), + pending_builds: Default::default(), } } @@ -360,7 +361,7 @@ impl Server { params.text_document.text, language, Owner::Client, - TextSize::default(), + LineCol { line: 0, col: 0 }, ); self.update_workspace(); @@ -387,28 +388,18 @@ impl Server { workspace.edit(&uri, range, &change.text); } None => { + let new_line = document.cursor.line.min(change.text.lines().count() as u32); let language = document.language; - let line_col = document.line_index.line_col(document.cursor); - - let (_, new_cursor) = change - .text - .lines() - .fold_while((0, 0), |(number, index), line| { - if number == line_col.line { - FoldWhile::Done((number, index)) - } else { - itertools::FoldWhile::Continue((number + 1, index + line.len())) - } - }) - .into_inner(); - drop(document); workspace.open( uri.clone(), change.text, language, Owner::Client, - TextSize::from(new_cursor as u32), + LineCol { + line: new_line as u32, + col: 0, + }, ); } }; @@ -509,6 +500,9 @@ impl Server { let position = params.text_document_position.position; let client_capabilities = Arc::clone(&self.client_capabilities); let client_info = self.client_info.clone(); + + self.update_cursor(&uri, position); + self.run_query(id, move |db| { completion::complete( db, @@ -521,6 +515,16 @@ impl Server { Ok(()) } + fn update_cursor(&self, uri: &Url, position: Position) { + self.workspace.write().set_cursor( + uri, + LineCol { + line: position.line, + col: 0, + }, + ); + } + fn completion_resolve(&self, id: RequestId, mut item: CompletionItem) -> Result<()> { self.run_query(id, move |workspace| { match item @@ -582,17 +586,9 @@ impl Server { let mut uri = params.text_document_position_params.text_document.uri; normalize_uri(&mut uri); - let workspace = self.workspace.read(); - if let Some(document) = workspace.lookup(&uri) { - let position = document - .line_index - .offset_lsp(params.text_document_position_params.position); - - drop(workspace); - self.workspace.write().set_cursor(&uri, position); - } - let position = params.text_document_position_params.position; + self.update_cursor(&uri, position); + self.run_query(id, move |db| hover::find(db, &uri, position)); Ok(()) } @@ -672,6 +668,16 @@ impl Server { self.client .send_response(lsp_server::Response::new_ok(id, dot))?; } + "texlab.cancelBuild" => { + let pending_builds = Arc::clone(&self.pending_builds); + self.run_fallible(id, move || { + for pid in pending_builds.lock().drain() { + let _ = BuildCommand::cancel(pid); + } + + Ok(()) + }); + } _ => { self.client .send_error( @@ -728,6 +734,8 @@ impl Server { let command = BuildCommand::new(&workspace, &uri); let internal = self.internal_tx.clone(); let progress = self.client_capabilities.has_work_done_progress_support(); + let pending_builds = Arc::clone(&self.pending_builds); + self.pool.execute(move || { let guard = LOCK.lock(); @@ -738,14 +746,29 @@ impl Server { None }; - let status = match command.and_then(|command| command.run(sender)) { - Ok(status) if status.success() => BuildStatus::SUCCESS, - Ok(_) => BuildStatus::ERROR, - Err(why) => { + let status = command + .and_then(|command| { + let mut process = command.spawn(sender)?; + let pid = process.id(); + pending_builds.lock().insert(pid); + let result = process.wait(); + + let status = if pending_builds.lock().remove(&pid) { + if result?.success() { + BuildStatus::SUCCESS + } else { + BuildStatus::ERROR + } + } else { + BuildStatus::CANCELLED + }; + + Ok(status) + }) + .unwrap_or_else(|why| { log::error!("Failed to compile document \"{uri}\": {why}"); BuildStatus::FAILURE - } - }; + }); drop(progress_reporter); drop(guard); @@ -755,7 +778,7 @@ impl Server { let _ = client.send_response(lsp_server::Response::new_ok(id, result)); } - if fwd_search_after { + if fwd_search_after && status != BuildStatus::CANCELLED { let _ = internal.send(InternalMessage::ForwardSearch(uri, params.position)); } }); diff --git a/support/texlab/crates/texlab/tests/lsp/text_document/completion.rs b/support/texlab/crates/texlab/tests/lsp/text_document/completion.rs index 78df56c583..e76f4360bd 100644 --- a/support/texlab/crates/texlab/tests/lsp/text_document/completion.rs +++ b/support/texlab/crates/texlab/tests/lsp/text_document/completion.rs @@ -786,7 +786,7 @@ fn test_project_resolution_import() { r#" %! main.tex \documentclass{article} -\import{sub}{sub/sub.tex} +\import{sub}{sub.tex} \lipsu | ^^^^^ @@ -864,3 +864,51 @@ fn issue_883() { % Comment"# )) } + +#[test] +fn issue_885() { + assert_json_snapshot!(complete( + r#" +%! main.tex +\documentclass{book} +\usepackage{import} +\begin{document} +\subincludefrom{part 1}{main} +\include{part 2/main} + +\ref{sec} + | + ^^^ +\end{document} + +%! part 1/main.tex +\part{1} +\label{part 1} +\subimport{chapter 1}{main} + +%! part 1/chapter 1/main.tex +\chapter{1} +\label{chapter 1} +\subimport{./}{section 1} +%\subimport{}{section 1} + +%! part 1/chapter 1/section 1.tex +\section{1} +\label{section 1} + +%! part 2/main.tex +\part{2} +\label{part 2} +\input{part 2/chapter 2/main} + +%! part 2/chapter 2/main.tex +\chapter{2} +\label{chapter 2} +\input{part 2/chapter 2/section 2} + +%! part 2/chapter 2/section 2.tex +\section{2} +\label{section 2} +"# + )); +} diff --git a/support/texlab/crates/texlab/tests/lsp/text_document/snapshots/lsp__text_document__completion__issue_885.snap b/support/texlab/crates/texlab/tests/lsp/text_document/snapshots/lsp__text_document__completion__issue_885.snap new file mode 100644 index 0000000000..2f286288b9 --- /dev/null +++ b/support/texlab/crates/texlab/tests/lsp/text_document/snapshots/lsp__text_document__completion__issue_885.snap @@ -0,0 +1,18 @@ +--- +source: crates/texlab/tests/lsp/text_document/completion.rs +expression: "complete(r#\"\n%! main.tex\n\\documentclass{book}\n\\usepackage{import}\n\\begin{document}\n\\subincludefrom{part 1}{main}\n\\include{part 2/main}\n\n\\ref{sec}\n |\n ^^^\n\\end{document}\n\n%! part 1/main.tex\n\\part{1}\n\\label{part 1}\n\\subimport{chapter 1}{main}\n\n%! part 1/chapter 1/main.tex\n\\chapter{1}\n\\label{chapter 1}\n\\subimport{./}{section 1}\n%\\subimport{}{section 1}\n\n%! part 1/chapter 1/section 1.tex\n\\section{1}\n\\label{section 1}\n\n%! part 2/main.tex\n\\part{2}\n\\label{part 2}\n\\input{part 2/chapter 2/main}\n\n%! part 2/chapter 2/main.tex\n\\chapter{2}\n\\label{chapter 2}\n\\input{part 2/chapter 2/section 2}\n\n%! part 2/chapter 2/section 2.tex\n\\section{2}\n\\label{section 2}\n\"#)" +--- +[ + { + "label": "section 1", + "detail": "Section (1)", + "preselect": false, + "filterText": "section 1 Section (1)" + }, + { + "label": "section 2", + "detail": "Section (2)", + "preselect": false, + "filterText": "section 2 Section (2)" + } +] diff --git a/support/texlab/texlab.1 b/support/texlab/texlab.1 index 2cab4ed096..8d0ecbeb45 100644 --- a/support/texlab/texlab.1 +++ b/support/texlab/texlab.1 @@ -1,7 +1,7 @@ .\" DO NOT MODIFY THIS FILE! It was generated by help2man 1.47.13. -.TH TEXLAB "1" "May 2023" "texlab 5.5.1" "User Commands" +.TH TEXLAB "1" "May 2023" "texlab 5.6.0" "User Commands" .SH NAME -texlab \- manual page for texlab 5.5.1 +texlab \- manual page for texlab 5.6.0 .SH SYNOPSIS .B texlab [\fI\,OPTIONS\/\fR] diff --git a/support/texlab/texlab.pdf b/support/texlab/texlab.pdf Binary files differindex 14c3fc7c54..a7ed8d359f 100644 --- a/support/texlab/texlab.pdf +++ b/support/texlab/texlab.pdf |