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

Pressing 'q' does not close magit, but switches buffer instead. #43

Closed
slackhead opened this issue Nov 13, 2015 · 13 comments
Closed

Pressing 'q' does not close magit, but switches buffer instead. #43

slackhead opened this issue Nov 13, 2015 · 13 comments

Comments

@slackhead
Copy link

I've noticed that post 1.4 when I press 'q' in the playground it does not close the buffer, it simply switches to the file buffer, leaving playground open.

If I switch to the playground buffer and press 'q' then it will then close it and the file.

@jreybert
Copy link
Owner

There has been some recent changes around this.

Could you try the very last master branch and confirm that the problem persists?

@slackhead
Copy link
Author

Yes, I've tried with 1.4.2 today 14th Nov and then compared with 14.1. I also recloned the repo to see if I'd done something wrong.

@jreybert
Copy link
Owner

Are you on master or on tag 1.4.2?

Do you have the commit 795e280 ?

If your are up to date with 795e280 , could you describe more precisely your problem, including for example:

  • the output of :buffers before you open magit-playground, during it is opened, once it is closed
  • how do you open the magit playground
  • what is your vesion of vim

could you also provide a step by step command to reproduce the problem.

Thanks

@slackhead
Copy link
Author

If I checkout 795e280 the results are the same as with master. Tag is 1.4.2.

These are the steps:

I start vim
:buffers shows '1 %a "[No Name]" line 1'
I use leader m or type :Magit
I press 'q'
:buffers shows:
1 #a "[No Name]" line 1
2 %a "magit-playground" line 1
:bnext
I press 'q'
Playground closes
Vim exits if there are no unsaved files

Vim was built from git on 15/10/2015 (or 10/15 for USA)

@jreybert
Copy link
Owner

There's something I don't understand

I start vim
:buffers shows '1 %a "[No Name]" line 1'
I use leader m or type :Magit

could you give the :buffers output here?

I press 'q'
:buffers shows:
1 #a "[No Name]" line 1
2 %a "magit-playground" line 1

Right now, the active buffer IS magit-playground. Are you sure? It means that magit#close_magit() did not work.

:bnext

Now, I am totally lost. You were in magit-playground. With :bnext, you should now be in [No name]. If it is the case, 'q' should not be active here. Could you give me the output of :buffers again here?

I press 'q'
Playground closes
Vim exits if there are no unsaved files

And, could you source and execute such function from an empty vim and attach /tmp/log

function! Tests()
    redir! > /tmp/log
    echo "1"
    buffers
    echo "2"
    Magit
    buffers
    echo "3"
    call magit#close_magit()
    buffers
    redir END
endfunction

@slackhead
Copy link
Author

I don't know how to quote here, but:

"Right now, the active buffer IS magit-playground. Are you sure? It means that magit#close_magit() did not work."

That's what I'm saying - it doesn't close, it just switches vim to display the next buffer.

vim
buffers
1 %a "[No Name]" line 1
Magit
buffers
1 #a "[No Name]" line 1
2 %a "magit-playground" line 1
q
buffers
1 %a "[No Name]" line 1
2 h "magit-playground" line 0
bnext
buffers
1 #h "[No Name]" line 1
2 %a "magit-playground" line 1

log.txt

@jreybert
Copy link
Owner

Indeed, quit the magit buffer means hiding it. If I read the log correctly, press q hide the playground.

So, what do you expect with q?

@slackhead
Copy link
Author

In 1.4 it would close it and it wouldn't show in buffer list or airline buffer bar.

@slackhead
Copy link
Author

In function! magit#close_magit() how about using bdelete instead of close?

function! magit#close_magit()
try
bdelete
catch /^Vim%((\a+))=:E444/
try
edit #
catch /^Vim%((\a+))=:E%(194|499)/
quit
endtry
endtry
endfunction

@slackhead
Copy link
Author

Perhaps some screenshots will help to see what I mean:

I have 3 files open: a, b and c:
http://www.r0t.uk/sshots/shot-9182810054.png

:Magit
http://www.r0t.uk/sshots/shot-2609973000.png

After pressing 'q':
http://www.r0t.uk/sshots/shot-0297197584.png

:ls
http://www.r0t.uk/sshots/shot-1032706793.png

As you can see it is still visible in the airline buffer bar.

@jreybert
Copy link
Owner

Hi slackhead,

I did not forgot you! Thanks for the screenshots.

I am working on a solution, but there is some corner cases I want to fix before pushing it. I hope to push it in the next days.

@jreybert
Copy link
Owner

I believe it is fixed in branch next.

@slackhead
Copy link
Author

Thanks.

jreybert added a commit that referenced this issue Nov 30, 2015
* next:
  Update Changelog
  plugin/magit.vim: move s:magit_commit_mode to buffer variable b:magit_current_commit_mode
  plugin/magit.vim: move s:state to buffer variable b:state
  plugin/magit.vim: display commit mode in Info section
  syntax/magit.vim: rework section title color
  Update Changelog
  README,doc: add notes that magit handles multiple git repo
  README,doc: misc changes
  plugin/magit.vim: add mappings N and P to jump to next and previous hunk (fix #25)
  syntax/magit.vim: add some color in Info section
  plugin/magit.vim: disable inline help by default (fix #46)
  plugin/magit.vim: update inline help
  state.vim: display modified files first
  plugin/magit.vim: in show_magit(), always open buffer with :buffer command (fix #41)
  plugin/magit.vim,autoload/git.vim: yet another rework of magit#show_magit() (fix #41)
  plugin/magit.vim,autoload/{git,sign}.vim: magit can handle multiple git repository within one vim session (fix #44,#34,#29)
  plugin/magit.vim: add MagitOnly command
  plugin/magit.vim: better handling of magit buffer, including clean quit command (fix #43)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants