difftastic icon indicating copy to clipboard operation
difftastic copied to clipboard

Bug with template strings in js, ts

Open artman opened this issue 2 months ago • 1 comments

Noticed a diffing problem with template strings in js and ts that peculiarly is changes on whether a newline is present or not

If you have the following original:

const CommentsContainer = styled(Flex)`
  width: 100%;
  margin-top: 16px;

  ${props => props.$withSeparator && 
   `padding-top: 22px;`
  }
`;

and this modified:

const CommentsContainer = styled(Flex)`
  width: 100%;
  margin-top: 16px;
`;

Difftastic won't recognize that the last three lines of the template string have been removed, but will mark the entire template string as changed.

However, if you just remove one newline in the original before the last closing bracket, difftastic recognizes the deletion correctly:

const CommentsContainer = styled(Flex)`
  width: 100%;
  margin-top: 16px;

  ${props => props.$withSeparator && 
   `padding-top: 22px;`}
`;

The same thing as a CLI screenshot:

Image

artman avatar Oct 29 '25 11:10 artman

@Wilfred can I take this?

ptravers avatar Nov 13 '25 17:11 ptravers