neuron.vim icon indicating copy to clipboard operation
neuron.vim copied to clipboard

EditZettelLast not working

Open TanayB11 opened this issue 5 years ago • 6 comments

While I was editing my index file, I decided to create a new zettel (let's call it zettel2) with gzn. I made some changes and saved, but then when i used gzu (in normal mode) to go back, My response is simply the file name of zettel2.

I expected gzu to take me back to the index file, but that did not happen.

TanayB11 avatar Aug 04 '20 16:08 TanayB11

I have the same problem and in addition InsertZettelLast isn't working as well.

hoschi avatar Aug 05 '20 08:08 hoschi

  1. Editing zettel-1
  2. Create zettel-2 with gzn and save zettel-2 with :w.
  3. Last edited zettel is zettel-2 because last saved zettel is zettel-2.

We need penultimate edited zettel.

These changes should have made:

func! util#get_file_modified_last(dir, extension)
-	return system('ls -t '.shellescape(a:dir).'*'.a:extension.' | head -1')
+	return system('ls -t '.shellescape(a:dir).'*'.a:extension.' | head -2 | tail -1')

endf

Do we agreed?

0ihsan avatar Aug 05 '20 22:08 0ihsan

Actual result: zettel-2 is last zettel Expected result: zettel-1 is last zettel

Probably "Last zettel" is confusing, because I expect the Zettel before the last Zettel.

hoschi avatar Aug 06 '20 07:08 hoschi

Yes, looks like,

We need penultimate edited zettel.

But in that case, when user edits a zettel-1 and saves it, opens another file other than zettelkästen and presses gzu to last edited zettel then returning zettel-1 is expected. Getting penultimate zettel would be irrelevant.

I think we can solve this problem by checking whether or not the current buffer is a zettel when the user hits gzu.

if gzu pressed
   if current buffer is from zettelkästen; then
      open penultimate (last but one) zettel
   else if current buffer is not a zettel; then
      open last modified file in zettelkästen
   end
end

0ihsan avatar Aug 06 '20 09:08 0ihsan

that makes sense!

hoschi avatar Aug 06 '20 17:08 hoschi

The behavior of this command also confused me, I've implemented a way that felt more natural to me here: https://github.com/fiatjaf/neuron.vim/commit/220eb5cfbea08971a4e3185a354292d5a570090a

fiatjaf avatar Sep 09 '20 01:09 fiatjaf