From e2d9110a3b27369bebb5d713d0d2e40f86ce2e9e Mon Sep 17 00:00:00 2001 From: Niko Strijbol Date: Thu, 7 Mar 2024 22:09:24 +0100 Subject: [PATCH] Support all command variants --- .../LatexNonBreakingSpaceInspection.kt | 2 +- .../LatexNonBreakingSpaceInspectionTest.kt | 21 +++++++++++++++++++ 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/src/nl/hannahsten/texifyidea/inspections/latex/typesetting/spacing/LatexNonBreakingSpaceInspection.kt b/src/nl/hannahsten/texifyidea/inspections/latex/typesetting/spacing/LatexNonBreakingSpaceInspection.kt index c31d1cc59..136b81954 100644 --- a/src/nl/hannahsten/texifyidea/inspections/latex/typesetting/spacing/LatexNonBreakingSpaceInspection.kt +++ b/src/nl/hannahsten/texifyidea/inspections/latex/typesetting/spacing/LatexNonBreakingSpaceInspection.kt @@ -54,7 +54,7 @@ open class LatexNonBreakingSpaceInspection : TexifyInspectionBase() { /** * Commands redefined by cleveref, such that no non-breaking space is needed anymore. */ - private val cleverefRedefinitions = setOf(THREF, VREF, VREF_CAPITAL, VREFRANGE, FULLREF).map { it.commandWithSlash } + private val cleverefRedefinitions = listOf(THREF.commandWithSlash) + setOf(VREF, VREFRANGE, FULLREF).map { it.command }.flatMap { c -> listOf(c, "$c*", c.replaceFirstChar { it.uppercase() }) }.map { "\\" + it } override val inspectionGroup = InsightGroup.LATEX diff --git a/test/nl/hannahsten/texifyidea/inspections/latex/typesetting/spacing/LatexNonBreakingSpaceInspectionTest.kt b/test/nl/hannahsten/texifyidea/inspections/latex/typesetting/spacing/LatexNonBreakingSpaceInspectionTest.kt index f92a09909..55d152d62 100644 --- a/test/nl/hannahsten/texifyidea/inspections/latex/typesetting/spacing/LatexNonBreakingSpaceInspectionTest.kt +++ b/test/nl/hannahsten/texifyidea/inspections/latex/typesetting/spacing/LatexNonBreakingSpaceInspectionTest.kt @@ -132,4 +132,25 @@ class LatexNonBreakingSpaceInspectionTest : TexifyInspectionTestBase(LatexNonBre """.trimIndent() ) } + + fun `test no warning when using cleveref`() { + myFixture.configureByText( + LatexFileType, + """ + \documentclass{article} + \usepakackage{varioref} + \usepackage{cleveref} + \begin{document} + \begin{figure} + Figure text. + \caption{Caption} + \label{fig:some-figure} + \end{figure} + + I ref \vref{fig:some-figure} + \end{document} + """.trimIndent() + ) + myFixture.checkHighlighting(false, false, true, false) + } } \ No newline at end of file