Skip to content

Commit fff423a

Browse files
committed
fix: tool formatting
1 parent 508cbaa commit fff423a

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/encoding.rs

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -820,31 +820,28 @@ impl Render<Message> for HarmonyEncoding {
820820
}
821821
};
822822

823+
// next header channel
824+
if let Some(channel) = &message.channel {
825+
self.render_formatting_token_into(FormattingToken::Channel, into)?;
826+
self.render_text_into(channel, into)?;
827+
}
828+
823829
// next render the header recipient, if there is one
824830
if let Some(recipient) = &message.recipient {
825831
if recipient != "all" {
826832
self.render_text_into(format!(" to={recipient}"), into)?;
827833
}
828834
}
829835

830-
// next header channel
831-
if let Some(channel) = &message.channel {
832-
self.render_formatting_token_into(FormattingToken::Channel, into)?;
833-
self.render_text_into(channel, into)?;
834-
}
835-
836836
// finally content type
837837
if let Some(content_type) = &message.content_type {
838-
// <|constrain|> is a unique case which needs to be tokenized as a special token
839838
if let Some(constrain_marker) =
840839
self.mapped_format_token(FormattingToken::ConstrainedFormat)
841840
{
842841
if let Some(rest) = content_type.strip_prefix(constrain_marker) {
843-
// Render the space, then the constrain marker as a special token, then the rest as text (if any)
844-
self.render_text_into(" ", into)?;
845-
self.render_formatting_token_into(FormattingToken::ConstrainedFormat, into)?;
842+
// Render the content type with mandatory leading space
846843
if !rest.is_empty() {
847-
self.render_text_into(rest, into)?;
844+
self.render_text_into(format!(" {rest}"), into)?;
848845
}
849846
} else {
850847
self.render_text_into(format!(" {content_type}"), into)?;

0 commit comments

Comments
 (0)