-
-
Notifications
You must be signed in to change notification settings - Fork 759
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
ToDo list #472
Comments
Filtering is case insensitive for english names, but case sensitive for russian.
"te" selects both "Test" and "test", while "те" selects only "тест" missing "Тест". It's expected to be case insensitive not depending on language. Tested on latest master. |
By default, we do use I think the issue may be with UTF8. As per the following man page: http://man7.org/linux/man-pages/man3/pcreposix.3.html diff --git a/src/nnn.c b/src/nnn.c
index a31b30e..571530e 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -2059,7 +2059,7 @@ static char xchartohex(char c)
static char * (*fnstrstr)(const char *haystack, const char *needle) = &strcasestr;
#ifdef PCRE
static const unsigned char *tables;
-static int pcreflags = PCRE_NO_AUTO_CAPTURE | PCRE_EXTENDED | PCRE_CASELESS;
+static int pcreflags = PCRE_NO_AUTO_CAPTURE | PCRE_EXTENDED | PCRE_CASELESS | PCRE_UTF8;
#else
static int regflags = REG_NOSUB | REG_EXTENDED | REG_ICASE;
#endif To compile with PCRE, run:
|
same behavior. |
I think either the library is not working correctly OR we need to do something extra that I am not aware of. I don't know Russian. Please raise a defect on libpcre and see what they have to say. |
Hm, I just retested, and if I filter by using regex (by doing So, when doing the regex filtering ( |
At the filter prompt:
When the prompt shows Try this without the patch: Start in string filter mode (default), press |
Testing without patch: in string search mode ( started:
search for "te" with default mode, shows both "test" and "Test" as expected:
searching for "te" in case sensitive mode ("noic") shows only "test" as expected:
searching for "те" in default mode shows only "тест", and not shows "Тест":
searching for "те" in case insensitive mode ("noic") shows only "тест" as expected:
searching for regex "te":
searching for regex "те" (without patch):
note, that is tested on latest master. I have 2.9 version installed in system, and surprisingly, regex searching in it works correct:
|
Did you build master with PCRE or without PCRE? |
|
OK. I compiled master without PCRE (and without patch):
And here's what I see:
Which I think is expected. My locale output:
|
For regex that's expected, yes. But string search gives different result. |
And yes, when I compile with PCRE (without the pacth), I do see the issue in regex. I think we need the patch for regex. I can repro the issue with string search with the above examples. In this case regex does not take effect as well. |
Also, with string search the issue exists in v2.9 as well. |
I think the problem is with using |
If I see the man page of
which essentially tells me |
converting to lowercase is also locale dependent, so it will not help. |
Iirc, normalizing UTF-8 strings is going to require a huge external library to help with normalizing it, and afaik it's not 100% foolproof. Btw, I would propose that regex keeps the I'm not in sync with |
Yes, I think it's not simple to achieve this. @alosich with the PCRE fix in, I would suggest you use regex (POSIX or PCRE) for this use case. We can document this limitation.
Hey, it looks cool and is easy to figure. Copy/paste carefully all the time. ;) |
works for me. |
I have updated the documentation here: https://github.com/jarun/nnn/wiki#limitation |
I have a question on the I think when we say, |
Implemented at commit ca257e6 as I had some time. But this is still open for discussion, |
I agree with what you did 👍 |
BTW, I am enjoying v3.0 (+ O_NOMOUSE) thoroughly. 3.0 feels like an achievement. |
Me too!
Huh, I didn't realize until now that mouse is supported, I never even thought to try to use mouse in nnn before 😄 |
I used to realize it now and then when clicking to bring the terminal above other windows. It reduces memory usage and binary size. On my system I have |
If you filter in a context, the filter will be gone when you return to that context after switching away. This was pretty annoying for some work I was doing. I tried to fix this but ran into a deadlock. It shows the correct results on the screen but stops responding to input :( diff --git a/src/nnn.c b/src/nnn.c
index 3e161db..9c6a3ba 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -4966,6 +4966,7 @@ begin:
blk_shift = BLK_SHIFT_512;
presel = CONTROL('L');
}
+ matches(g_ctx[cfg.curctx].c_fltr + 1);
#ifdef LINUX_INOTIFY
if (presel != FILTER && inotify_wd == -1) From what I read, when you change contexts, there's a switch-statement in Also I now realize that the UI could use work. It's not obvious when you return to a filtered context that you are seeing a subset of directory entries. You can press |
In which version are you? These are all fixed. In v3.0 the filter is retained and applied when you return to a context. And obviously the filter is shown in the filter prompt. |
git master
No it is not.
This is what I mean |
OK. I got the difference between your your use case and mine. I am in nav-as-you-type mode, you are not.
|
@JustAPerson please test with commit f0f8008. The previous one was not to my liking. |
When the below directory in an ext4 partition is entered and the du is toggled
However, when the same directory is copied to another ext4 partition with both
|
@lawnowner I think it's obvious I can't repro it on my system. Please enable debug logs and get your hands dirty. Also,
|
@lawnowner another option would be to compile in debug mode and run in gdb. When you get the segfault run |
Segv happens at the line 710 of nnn.c: |
Got it! A 32-bit HASH_BITS will increase the virtual memory usage drastically. So we need to figure a more efficient algo. |
@lawnowner diff --git a/src/nnn.c b/src/nnn.c
index ea37f2b..3dcf76b 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -702,6 +702,7 @@ static char *xitoa(uint val)
*/
static bool test_set_bit(ull nr)
{
+ nr = nr & HASH_BITS;
ull *m = ((ull *)ihashbmp) + (nr >> 6);
if (*m & (1 << (nr & 63)))
@@ -4179,7 +4180,7 @@ static void launch_app(const char *path, char *newpath)
static int sum_bsize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf))
{
if (sb->st_blocks && (typeflag == FTW_F || typeflag == FTW_D)
- && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino)))
+ && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino + (ull)sb->st_size)))
ent_blocks += sb->st_blocks;
++num_files;
@@ -4189,7 +4190,7 @@ static int sum_bsize(const char *UNUSED(fpath), const struct stat *sb, int typef
static int sum_asize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf))
{
if (sb->st_size && (typeflag == FTW_F || typeflag == FTW_D)
- && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino)))
+ && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino + (ull)sb->st_size)))
ent_blocks += sb->st_size;
++num_files;
@@ -4309,7 +4310,8 @@ static int dentfill(char *path, struct entry **dents)
}
} else {
/* Do not recount hard links */
- if (sb.st_nlink <= 1 || test_set_bit((ull)sb.st_ino))
+ if (sb.st_nlink <= 1
+ || test_set_bit((ull)sb.st_ino + (ull)sb.st_size))
dir_blocks += (cfg.apparentsz ? sb.st_size : sb.st_blocks);
++num_files;
}
@@ -4406,7 +4408,8 @@ static int dentfill(char *path, struct entry **dents)
} else {
dentp->blocks = (cfg.apparentsz ? sb.st_size : sb.st_blocks);
/* Do not recount hard links */
- if (sb.st_nlink <= 1 || test_set_bit((ull)sb.st_ino))
+ if (sb.st_nlink <= 1
+ || test_set_bit((ull)sb.st_ino + (ull)sb.st_size))
dir_blocks += dentp->blocks;
++num_files;
} |
@lawnowner ignore the previous patch. Try the following (I have reduced the hash bits further): diff --git a/src/nnn.c b/src/nnn.c
index ea37f2b..24fe374 100644
--- a/src/nnn.c
+++ b/src/nnn.c
@@ -165,7 +165,7 @@
#define BLK_SHIFT_512 9
/* Detect hardlinks in du */
-#define HASH_BITS (0xFFFFFF)
+#define HASH_BITS (0xFFFF)
#define HASH_OCTETS (HASH_BITS >> 6) /* 2^6 = 64 */
/* Program return codes */
@@ -702,6 +702,7 @@ static char *xitoa(uint val)
*/
static bool test_set_bit(ull nr)
{
+ nr = nr & HASH_BITS;
ull *m = ((ull *)ihashbmp) + (nr >> 6);
if (*m & (1 << (nr & 63)))
@@ -4179,7 +4180,7 @@ static void launch_app(const char *path, char *newpath)
static int sum_bsize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf))
{
if (sb->st_blocks && (typeflag == FTW_F || typeflag == FTW_D)
- && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino)))
+ && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino + (ull)sb->st_size)))
ent_blocks += sb->st_blocks;
++num_files;
@@ -4189,7 +4190,7 @@ static int sum_bsize(const char *UNUSED(fpath), const struct stat *sb, int typef
static int sum_asize(const char *UNUSED(fpath), const struct stat *sb, int typeflag, struct FTW *UNUSED(ftwbuf))
{
if (sb->st_size && (typeflag == FTW_F || typeflag == FTW_D)
- && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino)))
+ && (sb->st_nlink <= 1 || test_set_bit((ull)sb->st_ino + (ull)sb->st_size)))
ent_blocks += sb->st_size;
++num_files;
@@ -4309,7 +4310,8 @@ static int dentfill(char *path, struct entry **dents)
}
} else {
/* Do not recount hard links */
- if (sb.st_nlink <= 1 || test_set_bit((ull)sb.st_ino))
+ if (sb.st_nlink <= 1
+ || test_set_bit((ull)sb.st_ino + (ull)sb.st_size))
dir_blocks += (cfg.apparentsz ? sb.st_size : sb.st_blocks);
++num_files;
}
@@ -4406,7 +4408,8 @@ static int dentfill(char *path, struct entry **dents)
} else {
dentp->blocks = (cfg.apparentsz ? sb.st_size : sb.st_blocks);
/* Do not recount hard links */
- if (sb.st_nlink <= 1 || test_set_bit((ull)sb.st_ino))
+ if (sb.st_nlink <= 1
+ || test_set_bit((ull)sb.st_ino + (ull)sb.st_size))
dir_blocks += dentp->blocks;
++num_files;
} |
The segmentation fault returns after decreasing the variable width from ull to ulong at the commit c6cc8a5. You can reproduce the issue with test_set_bit() by setting the nr value in gdb regardless of whether your file system naturally produces it or not, but now the segv occurs even in the system directories (e.g. /usr) when the du toggle is switched. |
Yes, I have to reduce the width as well. I had to leave after the change. I'll fix it and update you to confirm. |
@lawnowner please confirm with commit 9535668. I think it's fixed now. |
@jarun I noticed that if you remove a file in Do you know if this is something that can be easily done? I tried to look into the code but it's not immediately obvious to me where this selection happens after you delete a file. |
@maximbaz I think it can be done easily. I'll make the change. |
This works somewhat.
Valgrind says this is because of uninitalized memory (these line numbers are f0f8008):
I first noticed this bug on f0f8008 but it occurs on the commit before and also master. I can find even more undefined behavior on master (these line numbers are from 76cf0c6):
I also found a segfault at one point doing some random stuff but that one is harder to replicated. |
That's the intention. With different filters applied and 4 contexts open, this is indeed helpful. What problem are you facing? Despite the filter showing there, up, down, enter. control keypresses work seamlessly. You do not need to clear the filter with
I can't reproduce this! More detailed steps please. Are you restoring from a session? When you press |
|
@JustAPerson in
and see what keypress you get when you press |
On 76cf0c6
I definitely think you should pursue fixing any undefined behavior in I will not be responding to this issue further. |
@JustAPerson nnn uses a shortcut to remember the last filter in-place in |
Rolled from #448.
For next release
NNN_OPTS
to specify binary options tonnn
s
in status bar to indicate selection in progressO_NOMOUSE
to disable mouse supportNNN_TRASH
and-Q
always, do not store in config/sessionProposed features and tasks (up for grabs)
vidir
-like functionality (@KlzXS)nnn.vim
plugin to show a persistent bar (Support vim popup mcchrish/nnn.vim#46)nnn
pluginsAnything else which would add value (please discuss in this thread).
The text was updated successfully, but these errors were encountered: