Skip to content

Commit 9fb9c0b

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

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

src/encoding.rs

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

823-
// next render the header recipient, if there is one
824-
if let Some(recipient) = &message.recipient {
825-
if recipient != "all" {
826-
self.render_text_into(format!(" to={recipient}"), into)?;
827-
}
828-
}
829-
830823
// next header channel
831824
if let Some(channel) = &message.channel {
832825
self.render_formatting_token_into(FormattingToken::Channel, into)?;
833826
self.render_text_into(channel, into)?;
834827
}
835828

829+
// next render the header recipient, if there is one
830+
if let Some(recipient) = &message.recipient {
831+
if recipient != "all" {
832+
self.render_text_into(" to", into)?;
833+
self.render_text_into(format!("={recipient}"), into)?;
834+
}
835+
}
836+
836837
// finally content type
837838
if let Some(content_type) = &message.content_type {
838-
// <|constrain|> is a unique case which needs to be tokenized as a special token
839839
if let Some(constrain_marker) =
840840
self.mapped_format_token(FormattingToken::ConstrainedFormat)
841841
{
842842
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)?;
843+
// Render the rest as text (if any)
846844
if !rest.is_empty() {
847-
self.render_text_into(rest, into)?;
845+
self.render_text_into(format!(" {rest}"), into)?;
848846
}
849847
} else {
850848
self.render_text_into(format!(" {content_type}"), into)?;

0 commit comments

Comments
 (0)