onivim / oni2

Native, lightweight modal code editor
https://v2.onivim.io
MIT License
7.84k stars 282 forks source link

File changes from other programs are not being updated #3725

Open raguay opened 3 years ago

raguay commented 3 years ago

Description

When you open a file in Oni2, make changes to it, save it, exit the file, make changes in another program or command line, and then reopen the file in Oni2, none of the changes are visible. If you save the file in Oni2, the changes to the file are overwriten.

Version

Nightly version as of 07/01/2021. macOS Big Sur version 11.4 (20F71)

Steps to reproduce

1) Open a file like test.txt and add some content. 2) Close the file in Oni2 without exiting Oni2. 3) Change the contents of test.txt with another program or command line. 4) Open the file again in Oni2 from the command line: oni2 test.txt

Expected result

The file should open in Oni2 with the changes from the second program.

Actual Results

The file shows up as it last was edited in Oni2.

This has been happening for a while and I thought there was already a Issue filed, but I could not find it.

CrossR commented 3 years ago

This may be an artefact of the vim buffer system.

When you say close the file, do you mean fully close it, or close the tab it is in? If its just the tab, we will keep it open in the background, so when you next open it, we carry on using the already opened version.

I believe that is the same behaviour as vim, at least without the autoread option set.

So since we aren't ever "reopening" the file, we don't reload those changes, unless you manually do a :e to load the file again.

raguay commented 3 years ago

Okay. I have to say that I'm not a vim guru, but I have grown to love it. I started my career in mainframes with emacs and have changed to nvim and Onivim since Onivim came out (version 1). I also use many pre-made setups. So my vanilla vim knowledge isn't that great.

Classically, I've used Vim on the command line by edits in and out. When I did start using nvim as an IDE, it was with the SpaceVim setup. I bet it has the autoread option preset.

When I would work with windowing IDEs, I usually still just run around in my file manager/command line (I use nnn a lot) and open files from it. With Onivim2, I've been using it in two ways: a full IDE that sits in a project and as a quick editor from the command line. Much like I used Emacs with Doomemacs config using the emacs server. One editor always open with some things that I just in and out of and other things I'm always working on. Therefore, I've really gotten used to that.

Therefore, is there a way that opening files from the command line invokes a full re-read? Or, is there a way to set the close tab (and <ctrl>-w) to always close the buffer as well as the tab pane? I haven't really figured out how to use the vim language to change Onivim2 like I can in neovim.

Thanks for your explanation and help.

raguay commented 3 years ago

I added this:

  "experimental.viml": ["set autoread", 
                        "au FocusGained,BufEnter * :silent! !",
                        "au FocusLost,WinLeave * :silent! noautocmd w"]

But, it still has the same problem. Even just the first line setting the autoread doesn't seem to work, but according to Stack Overflow, that option doesn't work on several vim types.

raguay commented 3 years ago

I found this that works on neovim to close a file and buffer, but I can't get it to work on Oni2:

map <leader>q :bp<bar>sp<bar>bn<bar>bd<CR>