Skip to content

fix: keep a literal % in logpoint messages that interpolate nothing - #2445

Merged
Connor Peet (connor4312) merged 1 commit into
microsoft:mainfrom
NgoQuocViet2001:fix-logpoint-percent
Oct 31, 2026
Merged

Connor Peet (connor4312) merged 1 commit into
microsoft:mainfrom
NgoQuocViet2001:fix-logpoint-percent

Conversation

@NgoQuocViet2001

Copy link
Copy Markdown
Contributor

A logpoint message with a literal % and no {expression} shows every % doubled in the Debug Console. 50% done logs 50%% done, while {1} 50% done logs 1 50% done. The compiler escapes % because the message becomes a console.log format string, but format specifiers are only applied when there is more than one argument, so with nothing interpolated the escape is never undone.

This uses the escaped format string only when at least one expression was interpolated, and passes the message through unchanged otherwise.

  • Ran: npm run test:unit -- --grep logMessageToExpression. The two new cases fail on main (console.log("50%% done, 100%%")) and pass with the change. The existing escaping case still covers the interpolated path.
  • Ran: npm run test:unit, no new failures (the 8 NodeBinaryProvider failures also happen on main).
  • Checked: npm run test:types, dprint check and eslint --max-warnings=0 on the touched files are clean.

@connor4312 Connor Peet (connor4312) left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks!

@connor4312
Connor Peet (connor4312) merged commit e9ae28c into microsoft:main Oct 31, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants