-
-
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
Strange behaviour when opening an empty file #187
Comments
|
I have tested |
I sort of figured out the problem... it's complicated. So I uninstalled mimeopen (the package name on manjaro is perl-file-mimeinfo) and now it doesn't open with mimeopen, but xdg-open instead. |
Probably you are seeing issue #181. |
I can open it with xdg-open and it works as it should. But when I try to open it inside nnn, it will open it in browser instead, but only after I close the terminal in which nnn is opened... any idea? |
are you on master? |
yes, I am |
if the empty file is |
Also, in your file manager, if you right click and see the properties which is the opener? |
|
This is all so strange. |
when you run xdg-open from a terminal, it can run vim because vim is a terminal utility. when you invoke it from another utility, i believe xdg-open detects it's is not called from a tty and it opens in the next best suitable gui application. Anyway, it's not an issue with nnn and you have the key |
|
I just tried this and I can confirm that this is happening. |
Gentlemen, My GUI FM is thunar. When I see the property of the empty file in Thunar, the "open with" application is Vim. When I double click on the file, it opens in Vim (in its own window). I see the same behaviour with nnn as well, i.e., when I press Enter, the file opens in vim (in its own window). I can't reproduce the issue you see. So I believe you guys have to debug this in your environment and figure out. It is handled here: |
To be more accurate for your cases, here: https://github.com/jarun/nnn/blob/master/src/nnn.c#L2764
|
@AvianY when you explicitly call |
It opens in the same terminal |
how do I use "DEBUG logs" ? |
Problem is somewhere inside
Now, I don't care much about this problem because I don't have empty files that I open with If the file is not empty there's no problem. |
Compile |
If I set the open with application to
|
I think the problem is If the file is a not a text file and the size is 0-byte, when Enter is pressed, show a message: |
|
So you mean the cli vim, right? (note that What happens if you set the open with application to some GUI editor, e.g. mousepad/leafpad/gedit and then try to open an empty file with |
In my case there's no problem with |
I am at a loss because I am unable to reproduce. Instead of new questions please get your hands dirty and debug the issue. |
To answer your question, nnn makes to difference if file is 0 or not today and invokes xdg-open assuming it will open a gui utility. |
Hahah, ok I won't bother you anymore. |
No it's intended. That's why to integrate with the desktop environment from the terminal.
I was thinking of handling the 0-byte file specially so it doesn't lead to the weird scenario. But I can't reproduce it. Now, if you set the file to be opened with a gui editor (other than vim), does it work as intended? |
I don't have a gui editor, otherwise I would try it. Weird that you can't reproduce it, it's really happening. I'll try later to patch nnn and use mimeopen instead of xdg-open, to see will it change anything. Again, I asked about 0byte file checking inside of nnn because I don't have a problem with xdg-open emptyfile, so I have to assume that there's a problem somewhere inside nnn. Have to go now for few hours but I'll let you know whether mimeopen changed anything or not. |
please refer to the code. |
manjaro-xfce-18.0.2-stable-x86_64 I can see the "open with" application is "mousepad" from thunar and
Please set your "open with" to a gui editor. Setting it to a CLI editor (like vim) would lead to unexpected behaviour as As an alternative, use the edit or open with option in |
It seems the behaviour of the default opener (xdg-open) varies across platforms and environments. Details are documented in the issue. To prevent an empty file from being accidentally opened leading to unexpected behaviour, we are adding a guard with the message that the empty file should be opened using edit or open option.
I have added a new config option to guard this case against accidental keypress. Yes, it can be annoying. |
See #187. The behaviour has always remained so confusing. In my case a 0B file opens in the GUI editor though I have NNN_USE_EDITOR set. We have a sensible message in place to help users with what to do next.
I am using zsh in alacritty.
When I try to open a file (with enter key or "L"), that is empty, it seemingly doesn't do anything, but instead starts to behave strangely.
I have to press each key twice to do something. And after I close nnn, a new "xterm" terminal opens up vim with that empty file I tried to open before, opened.
I apologise if this has been solved before, but I couldn't find anything like it
The text was updated successfully, but these errors were encountered: