Page 1 of 1

[TC9.51] Compare by content - very long row,edit mode inaccessible

Posted: 2021-02-07, 00:40 UTC
by BORG52
Hello

1/Download file:
2/try "Compare by Content" downloaded secureboot.js with any other file or with a little changed secureboot.js
- "Edit mode" is always inaccessible

Problem is here:
search for string in securebot.js:
var asmCryptoSha256Js

Here is very long row with 28425 chars.
After reduce it to 16350 chars, "edit mode" is now accessible.

It is bug or feature?
TC 9.51

Re: [TC9.51] Compare by content - very long row,edit mode inaccessible

Posted: 2021-02-07, 10:27 UTC
by Dalai
This is not a bug:
TC help, Dialog box: Compare by content wrote:Compare
Starts the comparison between the two chosen files. If the two files are identical, this will be shown with a dialog box only. Otherwise the differences will be shown in the two text windows. Binary files will be shown in hexadecimal mode, and text files in text mode. Files up to 2 MB will be loaded completely into memory, so the originals will remain editable. Larger files will only be mapped to memory, i.e. they remain locked during the comparison.
The size value is the sum of both of the file's sizes, i.e. TC locks files if they're a little over 1 MB in size.

This can be adjusted with this parameter:
TC help, section 4.b), 1. Configuration wrote:MaxCompareSizeInMem=1048576
Compare by content: Size limit for files which are loaded completely in memory for comparison. Larger files are mapped into memory.

@Ghisler: Although it's not a bug, it's a question that comes up more often. I suggest to add another hint to the help file explaining that Edit mode won't be available when the files are locked, because not everybody can make that connection or come to that conclusion.

Regards
Dalai

Re: [TC9.51] Compare by content - very long row,edit mode inaccessible

Posted: 2021-02-07, 12:49 UTC
by gdpr deleted 6
2Dalai
No, wrong rabbit hole :)

The file BORG52 has problems with is just approx. 214 KB in size. Just did a quick test (two files with 17 KB each, so in total only ~34 KB), it really seems to be about the line length. Go beyond a line length of somewhere between 16000 and 17000 characters (or perhaps bytes? I haven't tested with multi-byte characters), and no edit mode for ya...

It still seems to be a limitation though. If you compare two almost identical files with such very long lines, where only a few characters differ between the very long line(s) of the file, the file compare tool is not able to only highlight the differing characters, but highlights the whole very long line as different.

I find it curious, though, that the edit mode is disabled even though the viewer/editor component can still render the entire very long lines without issues, as it seems. The diff highlighting being limited should not affect the function of the editor, no?

Re: [TC9.51] Compare by content - very long row,edit mode inaccessible

Posted: 2021-02-07, 14:13 UTC
by Usher
elgonzo wrote: 2021-02-07, 12:49 UTC Go beyond a line length of somewhere between 16000 and 17000 characters (or perhaps bytes? I haven't tested with multi-byte characters), and no edit mode for ya...
It's 16 KiB buffer size limit. Many text editors allow even smaller line length so it's definitely not a bug. Results of editing such a file may be unexpected from users' point of view, so it's more safe to open it in read-only mode.

Re: [TC9.51] Compare by content - very long row,edit mode inaccessible

Posted: 2021-02-07, 14:16 UTC
by Dalai
2elgonzo
You're right. Still, adding information about file size, and line length for that matter, to the help file would be a good idea. Maybe a section dedicated to "Edit mode" and when and why it's disabled/unavailable.

Regards
Dalai

Re: [TC9.51] Compare by content - very long row,edit mode inaccessible

Posted: 2021-02-08, 15:34 UTC
by ghisler(Author)
Mapping to memory isn't the problem here, it's because of the extremely long line. Comparison within a line becomes slower and slower, the longer the line is. I had to set a limit where the lines are not compared any more, and also can't be edited.