lambdalisue / jupyter-vim-binding

Jupyter meets Vim. Vimmer will fall in love.
2.1k stars 136 forks source link

Stay in insertMode after window blur #30

Closed wilzbach closed 8 years ago

wilzbach commented 8 years ago

Hey,

yep yet another PR from me ;-)

I have noticed that Jupyter automatically unfocuses the current cell on a window.blur event (e.g. shifting the focus to a different tab) and they also issue a focus call once the window gains the focus again. This means that we will leave and the enter the edit mode and thus we will exit the insertMode in handle_edit_mode.

Here I propose a simple fix to stay in the insertMode if we blurred the window before.

lambdalisue commented 8 years ago

Thanks for implementation :-) Well, please make more clear comment and variable name while the situation is a bit complicated.

Case 1

  1. Hit i on a cell to get into 'normal mode (edit mode)'
  2. Hit i on a cell to get into 'insert mode'
  3. Click space outside of the cell to loose focus of the cell
  4. Click the cell and we expect normal mode

Case 2

  1. Hit i on a cell to get into 'normal mode (edit mode)'
  2. Hit i on a cell to get into 'insert mode'
  3. Click a different tab to loose focus of the window
  4. Return back to the jupyter tab and we expect insert mode

wasInInsertBeforeBlur should be wasInInsertBeforeWindowBlur or whatever and the comment // except we were in insert mode before the last blur is not really correct.

lambdalisue commented 8 years ago

@greenify I perform some refactoring so please update to the latest