Edgewall Software
Modify

Opened 17 years ago

Closed 17 years ago

#4557 closed defect (fixed)

Diff shows tab as only 7 spaces when part of intraline changes

Reported by: Tim Hatch Owned by: Tim Hatch
Priority: normal Milestone: 0.11
Component: version control/changeset view Version: devel
Severity: normal Keywords: diff
Cc: Branch:
Release Notes:
API Changes:
Internal Changes:

Description

Evident in t.e.o in the changeset r4591, confirmed an issue on trunk. It's because of the way expandtabs() is being done in source:trunk/trac/versioncontrol/diff.py lines 176 and 180 and the \0 from markup_intraline_changes counts as a character, but is then removed to insert the tag, making the expanded line-that-used-to-have-a-tab now only start with 7 spaces.

For example, edit '\ta' to ' a' and you'd expect them to end up the same length in the diff. The way I'd like to fix this is with a custom version of expandtabs that takes a list of zero-width characters such as ('\0', '\1').

Attachments (2)

t4557.diff (2.8 KB ) - added by Tim Hatch 17 years ago.
no_expandtabs-r4597.diff (2.2 KB ) - added by Christian Boos 17 years ago.
Another approach, seems to work as well

Download all attachments as: .zip

Change History (7)

by Tim Hatch, 17 years ago

Attachment: t4557.diff added

comment:1 by Tim Hatch, 17 years ago

Keywords: review added

See attachment:t4557.diff for a rough draft. I think it ought to have some tests too.

Ideas?

by Christian Boos, 17 years ago

Attachment: no_expandtabs-r4597.diff added

Another approach, seems to work as well

comment:2 by Christian Boos, 17 years ago

Milestone: 0.11

Your patch made me wonder if we couldn't get rid of expandtabs completely, as we already to some processing on the line with the space_re and htmlify.

The proof-of-concept patch seems to work fine, for a simple test at least ;)

comment:3 by Tim Hatch, 17 years ago

Minor bits just noticed with both patches:

  • attachment:t4557.diff doesn't need to use the special expandtabs in the tag == 'equal' case, it could use the c-optimized regular one. Also the special expandtabs is a nop if there is not \t in the text, this is actually the common case for most of my files so should probably be checked
  • attachment:no_expandtabs-r4597.diff has an issue because tabstops hop to the next tabstop, they aren't just "worth 8 spaces". For example, '1234567\t' would be 8 characters wide, as would '1234\t'`.

in reply to:  3 comment:4 by Christian Boos, 17 years ago

Replying to thatch:

tabstops hop to the next tabstop, they aren't just "worth 8 spaces".

oops :) True.

Ok, so yours with the 2 optimizations (check if \t present and check for 'equal) seems the way to go.

comment:5 by Tim Hatch, 17 years ago

Keywords: review removed
Resolution: fixed
Status: newclosed

Applied modified patch in r4603.

Modify Ticket

Change Properties
Set your email in Preferences
Action
as closed The owner will remain Tim Hatch.
The resolution will be deleted. Next status will be 'reopened'.
to The owner will be changed from Tim Hatch to the specified user.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.