dhruvasagar / vim-dotoo

Org-mode like task logging & time tracking in Vim
558 stars 27 forks source link

Capturing tasks puts tasks in the wrong file #106

Closed amagee closed 2 years ago

amagee commented 3 years ago

I've experienced this on v0.12.7 and on revision 43d242c95a8b8e0356f1bbba127ecee07aa98a9b .

My relevant dotoo settings:

let g:dotoo#agenda#files = [expand('~/docs/dotoo/*.dotoo')]
let g:dotoo#capture#refile = expand('~/docs/dotoo/refile.dotoo')

I hit gCt to enter a todo, edit some of the todo information, and hit :wq to save. Instead of putting the todo into ~/docs/dotoo/refile.dotoo, it puts it into a file in /tmp.

Interestingly, the problem is specific to tasks. Phone calls, habits, meetings & notes all work.

dhruvasagar commented 3 years ago

@amagee Are you saying that they remain in that tmp file even after you close the capture window ?

amagee commented 3 years ago

Yes.

On Thu, Apr 1, 2021 at 1:36 PM Dhruva Sagar @.***> wrote:

@amagee https://github.com/amagee Are you saying that they remain in that tmp file even after you close the capture window ?

— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub https://github.com/dhruvasagar/vim-dotoo/issues/106#issuecomment-811594449, or unsubscribe https://github.com/notifications/unsubscribe-auth/AANOHT74LTQ2RCXUQEX5GGLTGPL35ANCNFSM42GABMCQ .

-- Andrew Magee Software engineer

e: @.*** p: 0403 642 438 li: https://www.linkedin.com/in/andrew-magee-7b66b821/

amagee commented 3 years ago

Oh, I also just noticed that applying the patch from https://github.com/dhruvasagar/vim-dotoo/pull/104/commits/2d2fc2272cb4bf072219de45cb78567e9c428318 fixes the problem.

dhruvasagar commented 3 years ago

@amagee I will investigate this and try to address it in a better way

dhruvasagar commented 3 years ago

@amagee Also what I have noticed in the past is if there happens to be a buffer named refile it can create issues. This particular issue you describe should ideally be fixed with the latest changes, however, if you're using vim sessions, it may be so that there is a buffer with the name refile and that would cause this problem, even if the file happened to not exist.

R2robot commented 3 years ago

It's not sometimes for me, it's every time. I abandoned this once before because it's been a struggle to learn it, but as it turns out, it wasn't me... it just doesn't work. flips the desk

dhruvasagar commented 3 years ago

@R2robot It does work for me. I can help fix the issue for you if are able to provide some details about the exact problem. Sorry you feel this wya.

dhruvasagar commented 3 years ago

@R2robot @amagee There have been changes made to the capture system recently, I believe this problem should not exist. However, if you continue to face issues I am happy to debug it with you and help you resolve it.

wrigleyster commented 2 years ago

I believe perhaps this issue is in the usage pattern? I was experiencing something similar. I was using gCt to open the capture window, typing in my headline, and then closing the buffer using :x or wq, but my refile.dotoo file would not update.

Looking around in the code however, I noticed in dotoocapture.vim that the autocmd is triggered by BufferHidden which is not triggered by the above save and exit.. however, executing instead :w followed by :bd then suddenly the refile.dotoo would update. Thus I wonder is this how you trigger the closing of the capture buffer, or how do you save and close?

Alternatively.. changing BufferHidden to BufferLeave fixes the issue for me, and works on my machine in all 3 scenarios I tested:

dhruvasagar commented 2 years ago

@wrigleyster thanks for the detail. BufLeave is triggered also when you move cursor away from the buffer to another buffer (split, tab), hence I am using BufferHidden. However, I use :wq and that works for me.

deanmarano commented 2 years ago

I believe I'm experiencing this as well. I'm on a M1 Mac, using iTerm2. I've tested using the system vim (8.2.4113) and homebrew vim (8.2.4950) I installed vim-dotoo (57ff147), set the following in my vim config:

let g:dotoo#agenda#files=[expand('~/nextcloud/dotoo/*.dotoo')]
let g:dotoo#capture#refile=expand('~/nextcloud/dotoo/refile.dotoo')

I created the directory and the refile.dotoo file, as well as put the dotoo.dotoo example file in the ~/nextcloud/dotoo/ for testing.

When I hit gCt, I'm able to open the capture split and select todo, and it opens a file at:

/var/folders/w7/lkztqnrn003dqzw4fs_nptnm0000gn/T/vim5OiU/20 [+] 

After I save (:w, :x, :wq), I expect to see that todo in my refile (using gAr). However it's empty.

If I look at the tmp folder mentioned above, the todo is still there. I'm not super familiar with vim script but have been using vim for a while.

Any ideas?

dhruvasagar commented 2 years ago

@deanmarano This is likely a vim specific error, can you share your vim version ?

deanmarano commented 2 years ago

I've tried using both the system vim (8.2.4113) and vim installed from homebrew (8.2.4950)

$ vim --version
VIM - Vi IMproved 8.2 (2019 Dec 12, compiled May 13 2022 20:56:28)
macOS version - arm64
Included patches: 1-4950
Compiled by Homebrew

Full output here (https://gist.github.com/deanmarano/8ecfe9a885cd87fe73a7b5e06db0899e)

My vimrc is in my dotfiles repo here https://github.com/deanmarano/dotfiles/blob/dotoo/.vimrc

I also tried this on my raspberry pi, on there the files just stayed in /tmp.

dean@cellar-door:~/dotfiles$ vim --version
VIM - Vi IMproved 8.1 (2018 May 18, compiled Jun 15 2019 16:41:15)
Included patches: 1-875, 878, 884, 948, 1046, 1365-1368, 1382, 1401
deanmarano commented 2 years ago

I've been testing this out with a minimal config.

https://gist.github.com/deanmarano/fc97b590fff17849fc41bb9ca385114c

Interestingly, the problem is specific to tasks. Phone calls, habits, meetings & notes all work.

I can reproduce this with the above vimrc. All capture types go into the refile properly except todos. Those go into a refile in the current directory.

deanmarano commented 2 years ago

I think it's related to the refactor here: https://github.com/dhruvasagar/vim-dotoo/commit/e1668712e0dd6c24bf29a893014be919511ba07e#diff-70460992ba9204c192eb0af9baf66c6cfb3e6634250353517158e975b250218dR85 I'm not sure how the refile:Tasks was working before this, but it seems to have broken for some users.

As @amagee mentioned:

Oh, I also just noticed that applying the patch from https://github.com/dhruvasagar/vim-dotoo/commit/2d2fc2272cb4bf072219de45cb78567e9c428318 fixes the problem

This resolves the issue. While applying this change, I found that the missing todos were being logged into my vim-dotoo plugin directory at ~/.vim/bundle/vim-dotoo/refile.

dhruvasagar commented 2 years ago

@deanmarano Are you overriding capture templates ?

dhruvasagar commented 2 years ago

@deanmarano I am unable to reproduce this issue so it's hard to test. I did however find a minor issue that I have corrected and pushed an update, can you or someone else verify if this solves the issue ?

deanmarano commented 2 years ago

The fix you pushed worked! Thank you!

dhruvasagar commented 2 years ago

If this is still an issue let me know, i'll open the issue and investigate.