From 712078985bf2e321535ef6d43c928ad160fec4f6 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Fri, 20 Dec 2024 15:34:31 +0100 Subject: [PATCH 1/2] Fix line endings for bibtex entry from remote file --- CHANGELOG.md | 1 + .../completion/handlers/LatexReferenceInsertHandler.kt | 9 +++++++-- src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt | 4 ++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cbb94bb35..80e5477e9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,7 @@ ## [Unreleased] ### Added +* Fix auto import from local bibtex file on Windows * Add sections to breadcrumbs * Change order in structure view to match source file and sectioning level * Add command redefinitions to command definition filter in structure view diff --git a/src/nl/hannahsten/texifyidea/completion/handlers/LatexReferenceInsertHandler.kt b/src/nl/hannahsten/texifyidea/completion/handlers/LatexReferenceInsertHandler.kt index f089d7ce7..d343e3f44 100644 --- a/src/nl/hannahsten/texifyidea/completion/handlers/LatexReferenceInsertHandler.kt +++ b/src/nl/hannahsten/texifyidea/completion/handlers/LatexReferenceInsertHandler.kt @@ -5,9 +5,11 @@ import com.intellij.codeInsight.completion.InsertionContext import com.intellij.codeInsight.lookup.LookupElement import nl.hannahsten.texifyidea.file.BibtexFile import nl.hannahsten.texifyidea.psi.BibtexEntry +import nl.hannahsten.texifyidea.psi.LatexPsiHelper import nl.hannahsten.texifyidea.settings.TexifySettings import nl.hannahsten.texifyidea.util.files.bibtexIdsInFileSet import nl.hannahsten.texifyidea.util.files.referencedFileSet +import nl.hannahsten.texifyidea.util.parser.firstChildOfType /** * @author Sten Wessel @@ -20,10 +22,13 @@ class LatexReferenceInsertHandler(private val remote: Boolean = false, private v if (remote and TexifySettings.getInstance().automaticBibtexImport) { remoteBib ?: return + // remoteBib may come from a file with CRLF line separators, which cannot be accepted into a psi file, so we need to fix that + val newBibEntry = LatexPsiHelper(context.project).createBibtexFromText(remoteBib.text.replace("\r\n", "\n")).firstChildOfType(BibtexEntry::class) ?: return + val bibsInFile = context.file.originalFile.bibtexIdsInFileSet() // Add the bib item after the last item we found in the file set, and hope that that makes sense... bibsInFile.lastOrNull()?.let { - it.parent.addAfter(remoteBib, it) + it.parent.addAfter(newBibEntry, it) } // If there are no bib items in the fileset yet, see if there is a(n empty) bib file we can add the bib entry to. @@ -31,7 +36,7 @@ class LatexReferenceInsertHandler(private val remote: Boolean = false, private v context.file.originalFile .referencedFileSet() .firstOrNull { it is BibtexFile } - ?.add(remoteBib) + ?.add(newBibEntry) } } } diff --git a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt index e5b24dde0..635a5c751 100644 --- a/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt +++ b/src/nl/hannahsten/texifyidea/psi/LatexPsiHelper.kt @@ -6,6 +6,7 @@ import com.intellij.psi.PsiFile import com.intellij.psi.PsiFileFactory import com.intellij.psi.PsiWhiteSpace import com.intellij.psi.impl.source.tree.LeafPsiElement +import nl.hannahsten.texifyidea.grammar.BibtexLanguage import nl.hannahsten.texifyidea.grammar.LatexLanguage import nl.hannahsten.texifyidea.psi.LatexTypes.* import nl.hannahsten.texifyidea.util.Log @@ -57,6 +58,9 @@ class LatexPsiHelper(private val project: Project) { fun createFromText(text: String): PsiFile = PsiFileFactory.getInstance(project).createFileFromText("DUMMY.tex", LatexLanguage, text, false, true) + fun createBibtexFromText(text: String): PsiFile = + PsiFileFactory.getInstance(project).createFileFromText("DUMMY.bib", BibtexLanguage, text, false, true) + /** * Adds the supplied element to the content of the environment. * @param environment The environment whose content should be manipulated From eb222e969637a8cac58e0b9c6d9bd09a58369890 Mon Sep 17 00:00:00 2001 From: Thomas Schouten Date: Sat, 21 Dec 2024 11:14:43 +0100 Subject: [PATCH 2/2] 0.9.10-alpha.4 --- CHANGELOG.md | 26 ++++++++++++++++++++++++-- gradle.properties | 2 +- 2 files changed, 25 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 073f0d8ae..0ee685d59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,16 +3,36 @@ ## [Unreleased] ### Added -* Fix auto import from local bibtex file on Windows + +### Fixed + +## [0.9.10-alpha.4] - 2024-12-21 + +### Added + * Add sections to breadcrumbs * Improve performance when starting a run configuration and when using autocompletion directly after starting the IDE * Change order in structure view to match source file and sectioning level * Add command redefinitions to command definition filter in structure view * Add support for automatic language injection on the minted environment * Add support for automatic detection of custom command aliases for include commands +* Add support for DeclareGraphicsExtensions +* Add inspection to warn about a missing reference for a glossary occurrence +* Do not fold sections in a command definition +* Include optional parameters in spellcheck, if it contains text +* Improve performance of finding files to be indexed +* Show formatted file path in file not found inspection quickfix name +* Automatically index bibliography files outside the project that are included by an absolute path +* Disable quotes inspection when TeX ligatures are disabled by fontspec +* Inspections can now be suppressed for any single line, or block of text ### Fixed +* Fix auto import from local bibtex file on Windows +* Fix false positive for duplicate command definition inspection in if/else +* Fix LaTeX files not showing up when choosing main file in run configuration +* Fix various issues with the Grazie implementation, in particular default rules for Grazie Pro + ## [0.9.10-alpha.3] - 2024-12-15 ### Added @@ -28,6 +48,7 @@ * Inspections can now be suppressed for any single line, or block of text ### Fixed + * Fix false positive for duplicate command definition inspection in if/else * Fix LaTeX files not showing up when choosing main file in run configuration * Fix various issues with the Grazie implementation, in particular default rules for Grazie Pro @@ -479,7 +500,8 @@ Thanks to @jojo2357 and @MisterDeenis for contributing to this release! * Fix some intention previews. ([#2796](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2796)) * Other small bug fixes and improvements. ([#2776](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2776), [#2774](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2774), [#2765](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2765)-[#2773](https://github.com/Hannah-Sten/TeXiFy-IDEA/issues/2773)) -[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.10-alpha.3...HEAD +[Unreleased]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.10-alpha.4...HEAD +[0.9.10-alpha.4]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.10-alpha.3...v0.9.10-alpha.4 [0.9.10-alpha.3]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.10-alpha.2...v0.9.10-alpha.3 [0.9.10-alpha.2]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.9...v0.9.10-alpha.2 [0.9.9]: https://github.com/Hannah-Sten/TeXiFy-IDEA/compare/v0.9.8...v0.9.9 diff --git a/gradle.properties b/gradle.properties index 331ac6e97..19b3b3fd7 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,4 @@ -pluginVersion = 0.9.10-alpha.3 +pluginVersion = 0.9.10-alpha.4 # Info about build ranges: https://www.jetbrains.org/intellij/sdk/docs/basics/getting_started/build_number_ranges.html # Note that an xyz branch corresponds to version 20xy.z and a since build of xyz.*