annotate-snippets-rs icon indicating copy to clipboard operation
annotate-snippets-rs copied to clipboard

fix: Remove false positive line trimming

Open BurntSushi opened this issue 9 months ago • 1 comments

Previously, it was possible for a ... to be inserted when no trimming was actually done. For example:

  |
1 |   version = "0.1.0"
2 |   # Ensure that the spans from toml handle utf-8 correctly
3 |   authors = [
  |  ___________^
4 | |     { name = "Z...ALGO", email = 1 }
5 | | ]
  | |_^ RUF200
  |

After this fix, the ... is no longer inserted:

  |
1 |   version = "0.1.0"
2 |   # Ensure that the spans from toml handle utf-8 correctly
3 |   authors = [
  |  ___________^
4 | |     { name = "ZALGO", email = 1 }
5 | | ]
  | |_^ RUF200
  |

This is another low confidence fix where I'm not sure that it's right. But the implementation was previously seeming to conflate the line length (in bytes) versus the actual rendered length. So instead of trying to do some math to figure out whether an ellipsis should be inserted, we just keep track of whether the code line we write was truncated or not.

BurntSushi avatar Jan 08 '25 17:01 BurntSushi