Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
* develop:
  Toggle-able option to keep sublime open when quitting out of last file #782
  When quitting the last window (not counting a help window), exit ST
  Fix #780 Navigating in the command palette not working in (ST4)
  • Loading branch information
gerardroche committed Jul 7, 2021
2 parents d0ebb18 + 8aaf02c commit e43e360
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 8 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Expand Up @@ -2,7 +2,12 @@

All notable changes are documented in this file using the [Keep a CHANGELOG](http://keepachangelog.com/) principles.

## 1.24.0 - 2021-06-09
## 1.24.1 - 2020-07-07

* Fixed [#782](https://github.com/NeoVintageous/NeoVintageous/issues/782): Toggle-able option to keep sublime open when quitting out of last file #782
* Fixed [#780](https://github.com/NeoVintageous/NeoVintageous/issues/780): Navigating in the command palette not working in (ST4)

## 1.24.0 - 2020-06-09

### Added

Expand Down
8 changes: 7 additions & 1 deletion Default.sublime-keymap
Expand Up @@ -10,9 +10,15 @@
{"keys": ["p"], "command": "move", "args": {"by": "characters", "forward": false}, "context": [{"key": "control", "operand": "sidebar_tree"}]},
{"keys": ["q"], "command": "neovintageous", "args": {"action": "toggle_side_bar"}, "context": [{"key": "control", "operand": "sidebar_tree"}]},

// Overlay.
// Overlay support for Sublime Text 3.
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "lines", "forward": true}, "context": [{"key": "overlay_visible"}, {"key": "control", "operand": "overlay_control"}, {"key": "setting.vintageous_use_ctrl_keys"}]},
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": false}, "context": [{"key": "overlay_visible"}, {"key": "control", "operand": "overlay_control"}, {"key": "setting.vintageous_use_ctrl_keys"}]},

// Overlay.
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "lines", "forward": true}, "context": [{"key": "overlay_visible"}, {"key": "control", "operand": "overlay_control command_palette"}, {"key": "setting.vintageous_use_ctrl_keys"}]},
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": false}, "context": [{"key": "overlay_visible"}, {"key": "control", "operand": "overlay_control command_palette"}, {"key": "setting.vintageous_use_ctrl_keys"}]},
{ "keys": ["ctrl+j"], "command": "move", "args": {"by": "lines", "forward": true}, "context": [{"key": "overlay_visible"}, {"key": "control", "operand": "overlay_control goto_file"}, {"key": "setting.vintageous_use_ctrl_keys"}]},
{ "keys": ["ctrl+k"], "command": "move", "args": {"by": "lines", "forward": false}, "context": [{"key": "overlay_visible"}, {"key": "control", "operand": "overlay_control goto_file"}, {"key": "setting.vintageous_use_ctrl_keys"}]},
{ "keys": ["ctrl+n"], "command": "move", "args": {"by": "lines", "forward": true}, "context": [{"key": "overlay_visible"}, {"key": "control", "operand": "overlay_control"}, {"key": "setting.vintageous_use_ctrl_keys"}]},
{ "keys": ["ctrl+p"], "command": "move", "args": {"by": "lines", "forward": false}, "context": [{"key": "overlay_visible"}, {"key": "control", "operand": "overlay_control"}, {"key": "setting.vintageous_use_ctrl_keys"}]},

Expand Down
3 changes: 3 additions & 0 deletions Preferences.sublime-settings
Expand Up @@ -70,6 +70,9 @@
// Plugin: A port of https://github.com/tpope/vim-unimpaired.
"vintageous_enable_unimpaired": true,

// When quitting the last window (not counting a help window), exit ST.
"vintageous_exit_when_quiting_last_window": true,

// Delegate configured keys to be handled by Sublime Text.
//
// For example to use ctrl+f for find (native ST behaviour):
Expand Down
13 changes: 13 additions & 0 deletions nv/utils.py
Expand Up @@ -1223,3 +1223,16 @@ def restore_visual_repeat_data(view, mode: str, data: tuple) -> None:
end = view.full_line(end).b
view.sel().add(Region(begin, end))
set_mode(view, VISUAL_LINE)


def is_help_view(view) -> bool:
return view and view.is_read_only() and view.is_scratch() and '[vim help]' in view.name()


def view_count_excluding_help_views(window) -> int:
count = 0
for view in window.views():
if not is_help_view(view):
count += 1

return count
8 changes: 7 additions & 1 deletion nv/window.py
Expand Up @@ -18,6 +18,7 @@
import os

from NeoVintageous.nv.settings import get_cmdline_cwd
from NeoVintageous.nv.settings import get_setting
from NeoVintageous.nv.utils import set_selection
from NeoVintageous.nv.vim import status_message

Expand Down Expand Up @@ -240,8 +241,13 @@ def _close_active_view(window) -> None:


def window_quit_view(window, **kwargs) -> None:
# Need to get the setting before quiting the the view because if closing the
# last view there may not be a view to get the setting from.
exit_when_quiting_last_window = get_setting(window.active_view(), 'exit_when_quiting_last_window')

_close_view(window, **kwargs)
if len(window.views()) == 0:

if len(window.views()) == 0 and exit_when_quiting_last_window:
window.run_command('close')


Expand Down
8 changes: 3 additions & 5 deletions tests/functional/test__ex_help.py
Expand Up @@ -18,22 +18,20 @@
from sublime import CLASS_WORD_END
from sublime import CLASS_WORD_START

from NeoVintageous.nv.utils import is_help_view
from NeoVintageous.tests import unittest


class Test_ex_help(unittest.FunctionalTestCase):

def is_help_view(self, view):
return view.is_read_only() and view.is_scratch() and '[vim help]' in view.name()

def get_active_help_view(self):
av = self.view.window().active_view()
if self.is_help_view(av):
if is_help_view(av):
return av

def close_active_help_views(self):
for view in self.view.window().views():
if self.is_help_view(view):
if is_help_view(view):
view.close()

def tearDown(self):
Expand Down

0 comments on commit e43e360

Please sign in to comment.