Skip to content
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

Opening multiple threads breaks global $messages/$cur_thread #3

Closed
ff2000 opened this issue Nov 4, 2014 · 8 comments · Fixed by #9
Closed

Opening multiple threads breaks global $messages/$cur_thread #3

ff2000 opened this issue Nov 4, 2014 · 8 comments · Fixed by #9

Comments

@ff2000
Copy link
Collaborator

ff2000 commented Nov 4, 2014

You can

  • Open a linked MsgID
  • Open one msg, navigate back to search view, open another thread
    to reproduce the issue. Type ":ruby print $cur_thread" in the vim command entry, switch to another notmuch-show buffer and print the threadid again - they will be the same ;)
    Before the addition of folding this was not realized, but with folding vim totally get's screwed up, takes minutes to navigate between long threads, vim constantly at 100% CPU.

For a first quick fix I think making some of the global variables members of VIM::Buffer would be agood idea. I will prepare a patch if there are no objections.
In the long run IMHO refactoring a little bit (OOP?) might make the whole code more readable.

@ff2000
Copy link
Collaborator Author

ff2000 commented Nov 6, 2014

Hmmm,
I now moved $messages, $threads and $cur_thread inside VIM::Buffer. While this fixed (of course) the issues with wrong messages.count and cur_thread it still causes trouble with highlighting (and so with high vim CPU usage) It looks like it applies the wrong fold marks (leave all messages folded, change between notmuch-show-buffers: magically only parts of the message get unfolded).
I then added autocmd BufEnter,... before the folding syntax in s:show(), which fixed the above issue with moving between folders.
But now it never is folded on initial display. I was not able to find an event that matches this Buffer filling (neither BufRead nor BufWrite actions seem to apply) Any hint for this?

@ff2000
Copy link
Collaborator Author

ff2000 commented Nov 6, 2014

I just pushed the part that moves those variables inside VIM::Buffer:
ff2000@31ca6a1
As mentiond it's just half the fix.

@imain
Copy link
Owner

imain commented Nov 9, 2014

Interesting. Thanks a lot Franz!! I do think you are right, we should just refactor the code and pull out a .rb file too while we are at it. I'm travelling right now and won't be done until Friday so I won't be around too much.

@imain
Copy link
Owner

imain commented Nov 9, 2014

I made you a contributor to this repo.

imain pushed a commit that referenced this issue Nov 14, 2014
Make them members of VIM::Buffer.
First part of a fix for issue #3.
@imain
Copy link
Owner

imain commented Nov 14, 2014

I applied your change to master here. I'm going to do some refactoring, basically just pulling out the a .rb file for now. I figured I'd get your stuff in before that so you could continue in peace.

@ff2000
Copy link
Collaborator Author

ff2000 commented Dec 10, 2014

I commited a fix for issues with multiple nmshow buffers
https://github.com/ff2000/notmuch-vim/tree/fix_issues_with_multiple_nmshow_buffers
It basically is a switch from fdm=syntax to manual.
For the moment I bound it to "x", but IMHO it might be OK to merge into rb_show_view_magic.

I also discovered a conflict in Message end markers. It's always set to $curbuf.count, so one behind the actual end. get_message() assumed end to be the last line of the, message and probably there are even more places. If you don't mind I will got and set it (in rb_show) to b.count-1). (also affects full_headers_start etc.)

@ff2000
Copy link
Collaborator Author

ff2000 commented Dec 15, 2014

Just a little follow-up:
I just realised that manual folds get cached, so even after unfolding they can get folded with za, again. So we simply need to manually fold every part we want to be foldable and can then operate with normal vim fold shortcuts :)
I am going to implement this and put up a PR.

@imain what do you think about the approach for giving reoccuring operations like "is folded" or "unfold and align on top" a name (ruby function)?

@imain
Copy link
Owner

imain commented Dec 18, 2014

@ff2000 I'm not even sure what you mean to be honest :). If it fixes the problem I'm all for it. Great work on the latest changes btw, I just did a pull and am very happy with the changes!

@ff2000 ff2000 mentioned this issue Dec 22, 2014
@imain imain closed this as completed in #9 Jan 6, 2015
imain pushed a commit that referenced this issue Jan 6, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants