Closed ProgerXP closed 3 years ago
WIP, findings so far:
a[bc]d
- "bc") but part of the line after selection start (a[bc]d
- "bcd"); we will fix this; also, if the compared part is the same Notepad2 proceeds to compare full linesqsort()
); to implement this, we'd need to either edit them, add 4 more functions or merge all of them into one callback and do checks for Sort modes inside it instead of outside (less code but possibly slower) a[bc]d
<=> z[bc]y
)
a[bc]d
was after z[bc]y
prior to Sort then it will remain after)We have finished this and cleaned up the function along the way, removed redundant conditions and made the code less tangled (it's still pretty tangled though).
* Notepad2 has 4 callback functions (for `qsort()`); to implement this, we'd need to either edit them, add 4 more functions or merge all of them into one callback and do checks for Sort modes inside it instead of outside (less code but possibly slower)
We have replaced it with a single callback. There should be no performance penalty because it invokes one of standard sort functions (strncmp, etc.) using a pointer set up before qsort()
.
However, column mode (when column doesn't end on line break) + logical number comparison is slower than other modes because it's using WinAPI's StrCmpLogicalW()
but there is no "n" version (strcmp / strncmp) and we have to copy string parts to be compared into temporary buffers.
* line numbers are compared for ascending and descending sort modes (same order; descending doesn't cause later lines to be put first)
Line numbers are affected by asc/desc mode after all, it seems more logical.
@cshnik Let's make a final optimization: when using StrCmpLogicalW()
, don't use buffers if user has selected column that ends on line end. This is because if original compared strings end on \0
we don't have to copy them, we just pass the pointer to first compared character.
Let's make a final optimization: when using
StrCmpLogicalW()
, don't use buffers if user has selected column that ends on line end. This is because if original compared strings end on\0
we don't have to copy them, we just pass the pointer to first compared character.
Done.
Sort Lines (Alt+O) has 3 options to work with duplicate lines. However, they are using whole line even if Column sort is enabled - this should be changed.
Select the 2nd column and Sort using Merge lines. Notepad2 keeps both lines while after this change only the first line should be kept.
Also rename the Column sort checkbox to
Column sort and merge (rectangular selection)