-
Notifications
You must be signed in to change notification settings - Fork 4.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Files with only CR are shown as separated lines, but not line-sorted correctly #7735
Comments
The status bar reports "Unix (LF)" ? |
@xylographe is that a question? Yes, the status bar reports "Unix (LF)". The file is now attached by the way: |
To @xylographe 's point, you are defining a "line" to be some text that ends with a LF (per your "choice" as shown in the status bar), and then you are creating some data which doesn't follow the line definition and are expecting it to be sorted correctly? Suggest that you unify your example, so that line-endings used in the data match the line-ending type as shown on the status bar, and then see if sorting problems persist... |
@sasumner I should add that I am not defining anything since "Unix (LF)" was not my own choice, it was Notepad++'s choice based on a slightly more complete example file that I am uploading now.
(A real-word example would be captured terminal output for some Unix process with progress:
This file is being auto-detected as "Unix (LF)". Still, A, C and B are shown as separate lines with individual line numbers. Based on this result, I would expect Notepad++ to sort these lines. However, it does not, the ordered file is A-C-B-D. |
A similar issue appeared on the Live Support channel: sjzoppi Jun 08 13:36 sasumner Jun 08 13:41 sjzoppi Jun 08 13:41 sasumner Jun 08 13:47 sjzoppi Jun 08 13:48 sjzoppi Jun 08 14:07 sasumner Jun 08 14:10 sjzoppi Jun 08 14:16 sasumner Jun 08 14:24 sjzoppi Jun 08 14:26 sasumner Jun 08 14:27 sjzoppi Jun 08 14:28 sasumner Jun 08 14:28 sjzoppi Jun 08 14:29 sasumner Jun 08 14:31 sjzoppi Jun 08 14:31 |
I hit this problem. Anything shown as multiple lines should be treated as multiple lines by the line operations. In this case, if LF is the selection line terminating character, then either A) the entire file should appear on one line because it has no line endings, OR B) line operations should treat them as individual lines. |
Seems correct to me (presuming the middle part of your screenshot is the result). |
@Ekopalypse I agree. I don't care about the types of line endings, but I find your choice is reasonable. |
A few more users confused while sorting when line-endings are not 100% consistent in a file: |
In my opinion the bug here is that notepad++ is not making the fact that a file has mixed line-endings apparent to the user as soon as possible. It is a bug worth tackling because such files are tricky both for notepad++ (as this issue and others show) and for any other program that may consume the output of notepad++. I certainly do not expect notepad++ to always scan the entire text in order to check for mixed line-endings. That's a high price to pay when opening big files for a mostly rare reward. But notepad++ should let the user notice that he is "in dangerous waters" as soon as code is in a position to detect the issue (e.g. during rendering of text on screen). As for the UI, the best fix for me is this: only render a line break for the EOL byte-sequences that notepad++ expects as valid (e.g. when notepad displays A second best would be to display a big red warning (e.g. "Mixed line-endings detected") on the status bar (probably in the same place where the EOL type is shown now). Clicking the warning could be guiding you to the wikipedia article on the subject of line endings. P.S. P.P.S. |
I don't think letting the user choose a behavior is needed. What is there to choose between? The program should either sort lines with mixed line-endings, or disallow it entirely. |
If the program is allowed to sort lines with mixed endings, perhaps the
My C++ is a little rusty, plus I don't know if this is wanted, so I'm not doing a PR, just making a suggestion. |
BTW, there was recent discussion of this on the Community HERE. |
Or just warn the user and let him clean up the mess. (99% of the time leaving a file with mixed line endings will bite you down the road anyway) |
It appears you said this already back here: #7735 (comment) I kind of like your idea of showing really obviously the line-endings that don't match what Notepad++ thinks is the line-ending type of the entire file. Maybe it isn't a "mess"; maybe mixed line-endings are sometimes (OK, rarely, but not never) intentional. |
Maybe the simple solution to this issue is to "unify" the line-endings, to the declared line-endings of the file shown in the status bar, BEFORE running the sort. Sure, this changes more of the file content than simply reordering of the lines, but then this "issue" be solved. If "Paste" can unify line-endings (and it currently does when run from the Edit menu; see #9260 ), then why not the sorting commands doing the same? Also, if the last "line" of the file is included in the sort, and that line has zero length and thus no line-ending, it shouldn't be included in the sort. If the last "line" has content but no line-ending, it should be given a line-ending before sorting. |
I like the unify line endings idea but want to be prompted before the change is made. |
Description of the Issue
Sort the attached (Line Operations, Sort). The file consists of three lines (A, C, B), each terminated by only a carriage return (CR). In Hex, this is what this looks like:
This is what it looks like in Notepad++:
So the file is displayed as three separate "lines", so line-sorting should be expected to sort them. However, line-sorting does not sort the "lines".
Expected Behavior
Lines are sorted.
Actual Behavior
They are not
Debug Information
Notepad++ v7.8.1 (64-bit)
Build time : Oct 27 2019 - 22:57:19
Path : C:\Program Files\Notepad++\notepad++.exe
Admin mode : OFF
Local Conf mode : OFF
OS Name : Windows 10 Pro (64-bit)
OS Version : 1909
OS Build : 18363.535
Plugins : DSpellCheck.dll mimeTools.dll NppConverter.dll NppExport.dll
Maybe related: #4736
The text was updated successfully, but these errors were encountered: