commit cd8a0073527432abdd121c34540fb602b3baf914
Author: Juergen Spitzmueller <[email protected]>
Date: Sun Oct 18 11:27:43 2026 +0200
Fix space after command with Code style
A blank is always output as a blank, even if it terminates a command.
So let commands alsways be terminated with an empty group in this style.
---
src/Paragraph.cpp | 4 ++++
src/texstream.cpp | 5 ++++-
src/texstream.h | 7 +++++++
3 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/Paragraph.cpp b/src/Paragraph.cpp
index 9d47831b62..ec079d6371 100644
--- a/src/Paragraph.cpp
+++ b/src/Paragraph.cpp
@@ -1260,6 +1260,10 @@ void Paragraph::Private::latexSpecialChar(otexstream &
os,
{
char_type const c = owner_->getUChar(bparams, runparams, i);
+ // Styles that have blank as PassThruChar need bracket command
+ // termination.
+ os.forceBracketTermination(contains(style.pass_thru_chars, ' '));
+
// Special case: URLs with hyperref need to escape backslash, # and %
(#13012).
// Both a layout tag and a dedicated inset seem too much effort for
this.
string const hr_url_escape_chars = "\\#%";
diff --git a/src/texstream.cpp b/src/texstream.cpp
index 928a46e63a..4029e3d7d7 100644
--- a/src/texstream.cpp
+++ b/src/texstream.cpp
@@ -231,7 +231,10 @@ otexstream & operator<<(otexstream & ots, docstring const
& s)
ots.protectSpace(false);
}
if (ots.terminateCommand()) {
- if ((c == ' ' || c == '\0' || c == '\n') && !isprotected)
+ if (ots.forceBracketTermination() && !isprotected)
+ // Terminate with brackets.
+ otrs << "{}";
+ else if ((c == ' ' || c == '\0' || c == '\n') && !isprotected)
// A space or line break follows. Terminate with
brackets.
otrs << "{}";
else if (c != '\\' && c != '{' && c != '}')
diff --git a/src/texstream.h b/src/texstream.h
index e2922ae5fe..fa488941a6 100644
--- a/src/texstream.h
+++ b/src/texstream.h
@@ -83,6 +83,7 @@ public:
explicit otexstream(odocstream & os)
: otexrowstream(os), canbreakline_(false),
protectspace_(false), terminate_command_(false),
+ force_bracket_termination_(false),
parbreak_(true), blankline_(true), lastchar_(0) {}
///
void put(char_type const & c);
@@ -101,6 +102,10 @@ public:
///
bool terminateCommand() const { return terminate_command_; }
///
+ void forceBracketTermination(bool fbt) { force_bracket_termination_ =
fbt; }
+ ///
+ bool forceBracketTermination() const { return
force_bracket_termination_; }
+ ///
void lastChar(char_type const & c)
{
parbreak_ = (!canbreakline_ && c == '\n');
@@ -122,6 +127,8 @@ private:
///
bool terminate_command_;
///
+ bool force_bracket_termination_;
+ ///
bool parbreak_;
///
bool blankline_;
--
lyx-cvs mailing list
[email protected]
https://lists.lyx.org/mailman/listinfo/lyx-cvs