Pinning finding differences in a large file, bad html highlighting?

54 views
Skip to first unread message

James Reynolds

unread,
Aug 22, 2020, 7:50:33 AM8/22/20
to BBEdit Talk
I have 2 questions. I have a very large Lua file. I duplicated it and commented most of it out. Then I made some changes. I am trying to find the changes between the 2 documents but the difference engine keeps gobbling up more on one side than the other and then the comparison is useless because it's no longer in sync. This seems to happen most when one side has lines with just new lines and the other side has a comment "--". Is it possible to tell BBEdit to pin text in both documents at certain places so that no matter what the text is on either side, it will restart it's comparison at that point? Or is there some other way to manipulate how it's comparing things?

Second, it would be so nice if a text editor showed when an html tag was not correct, like
<div><div></div></div></div>. If the last one was highlighted in red or something it would be great. Is this possible now?

Greg Raven

unread,
Aug 23, 2020, 8:23:43 AM8/23/20
to BBEdit Talk
I don't understand the first part of your question, but as to the second part I have a question of my own: How would BBEdit know that the last closing DIV (in your example) is incorrect? What if that last DIV is in fact correct, but you erroneously left a closing DIV elsewhere in the document? FWIW, I use code folding to find the incorrect tags in situations such as this. This works especially well if your closing DIVs have comments after them as to which opening DIV they are supposed to match.

Darren Duncan

unread,
Aug 23, 2020, 5:01:52 PM8/23/20
to bbe...@googlegroups.com
As a frequent user of the difference engine, I understand and also request the
pinning feature James mentions. But I will follow-up and make a formal feature
request via the appropriate channel, and James I suggest you do likewise.

Greg, to explain: Pinning is a UI feature where you can explicitly tell BBEdit
that Line N on one side corresponds directly to line M on the other side, thus
overriding what BBEdit's algorithm determines what corresponds. Effectively the
user is partitioning the compared documents and explicitly saying, I want you to
treat what is above this line on each side as if it was the whole document, and
separately what is below this line.

James, lacking the explicit pinning feature, there are a number of tricks I have
employed over time to work around the lack of a formal pinning feature.

Low hanging fruit for your specific scenario that's good anyway is to use block
comments rather than line comments. If Lua supports block comments then use
them, as then the actual number of changed lines would be very minimized, just
an insertion at the top and bottom of the large commented blocks. If Lua
doesn't support block comments I would consider that a language design flaw.

Something I've done repeatedly is temporarily insert large enough blocks of
identical dummy text on both sides so that BBEdit's natural algorithm will treat
them as the same and thus partition the comparison at that point. This can be
done in as many places as needed. The dummy text would have to look very
different from the normal file contents.

Another thing that can help work around the problem is to do updates in stages
and do relatively few changes per stage. If one is using version control there
can be a commit between each stage.

A key thing I do is have separate stages for reordering blocks and doing other
kinds of edits. Or if I change the indenting that's a separate stage. This has
a key benefit also in that in the project's commit history its much easier to
see what changed, when stuff like reordering is separate commits from other
edits, and so on.

-- Darren Duncan

James Reynolds

unread,
Aug 23, 2020, 8:59:51 PM8/23/20
to bbe...@googlegroups.com
I guess code folding will work. Thanks.
James

James Reynolds

unread,
Aug 23, 2020, 8:59:51 PM8/23/20
to bbe...@googlegroups.com
Oh man, block comments are a no brainer. I feel so dumb now. Thank you! That's exactly the type of tip I was hoping for! Lua does have them.

For what it's worth, the difference engine in BBEdit is something I've learned to live on and I can't find any application that does anything as good as it (I've looked so I can have something on Linux). I've become so dependent on it that it's kind of forcing me to keep using the Mac platform.

James
Reply all
Reply to author
Forward
0 new messages