1

Sometimes a checktime causes a prompt to reload, even if the reloading would not change the buffer.

This can be demonstrated (neovim 0.5):

  1. Open file in vim1 (terminal 1)
  2. Open the same file in vim2 (terminal 2)
  3. Change the file in vim2, save it
  4. In vim1, run :checktime
  5. Decline the offer to reload
  6. In vim2, undo the change, and save the file
  7. In vim1, run :checktime
  8. vim offers to reload the file, even though the buffer contents are identical to what's on disk

The offer to reload seems to go against :help timestamps, which says:

When Vim notices the timestamp of a file has changed, and the file is being edited in a buffer but has not changed, Vim checks if the contents of the file is equal. This is done by reading the file again (into a hidden buffer, which is immediately deleted again) and comparing the text. If the text is equal, you will get no warning.

A git rebase can cause something analogous to the above sequence to occur, causing an automated checktime to offer to reload a file that's exactly the same as the buffer contents.

I would like to replace the checktime call with a function described in pseudocode:

if (check_file_timestamps_changed):
    if (buffer_contents != file_contents):
        checktime
    else:
        reset_checktime_counter

What viml magic functions should I use for the pseudocode:

  • check_file_timestamps_changed
  • buffer_contents != file_contents
  • reset_checktime_counter

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.