Skip to content

Commit

Permalink
fix various exit behaviour ex commands
Browse files Browse the repository at this point in the history
  • Loading branch information
gerardroche authored and eugenesvk committed Jan 6, 2024
1 parent 4c4164c commit 83ec805
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 20 deletions.
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt

### Added

* [#956](https://github.com/NeoVintageous/NeoVintageous/issues/956): Add `:exi[t]!` - same as `:wq!`
* [#956](https://github.com/NeoVintageous/NeoVintageous/issues/956): Add `:exit[!] [file]` - same as `:wq[!] [file]`
* [#956](https://github.com/NeoVintageous/NeoVintageous/issues/956): Add `:x[it]!` - same as `:wq!`
* [#956](https://github.com/NeoVintageous/NeoVintageous/issues/956): Add `:xit[!] [file]` - same as `:wq[!] [file]`
* [#373](https://github.com/NeoVintageous/NeoVintageous/issues/373): New Input Method plugin - Automatically switch the IM when entering and exiting Insert Mode
* [#948](https://github.com/NeoVintageous/NeoVintageous/issues/948): New `:delm[arks] {marks}` - Delete the specified marks. Marks that can be deleted include A-Z and 0-9.
* [#948](https://github.com/NeoVintageous/NeoVintageous/issues/948): New `:delm[arks]!` - Delete all marks for the current buffer, but not marks A-Z or 0-9.
Expand All @@ -70,6 +74,9 @@ All notable changes are documented in this file using the [Keep a CHANGELOG](htt

### Changed

* [#955](https://github.com/NeoVintageous/NeoVintageous/issues/947): ZZ is now the same as `:wq`
* [#956](https://github.com/NeoVintageous/NeoVintageous/issues/947): `:exi[t]` is now the same as `:wq`
* [#956](https://github.com/NeoVintageous/NeoVintageous/issues/947): `:x[it]` is now the same as `:wq`
* [#947](https://github.com/NeoVintageous/NeoVintageous/issues/947): :vnoremap and vunmap now include Select mode
* [#946](https://github.com/NeoVintageous/NeoVintageous/issues/946): :noremap and unmap now include Select mode

Expand Down
2 changes: 1 addition & 1 deletion nv/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -1740,7 +1740,7 @@ def run(self, mode=None, count=None, register=None):
class nv_vi_big_z_big_z(WindowCommand):

def run(self, mode=None, count=None, register=None):
do_ex_command(self.window, 'exit')
do_ex_command(self.window, 'wq')


class nv_vi_paste(TextCommand):
Expand Down
9 changes: 0 additions & 9 deletions nv/ex_cmds.py
Original file line number Diff line number Diff line change
Expand Up @@ -314,15 +314,6 @@ def ex_edit(window, view, file_name: str = None, forceit: bool = False, **kwargs
status_message("E37: No write since last change")


def ex_exit(window, view, **kwargs) -> None:
_do_write(view)

window.run_command('close')

if len(window.views()) == 0:
window.run_command('exit')


def ex_file(view, **kwargs) -> None:
msg = '"{}"'.format(view.file_name() if view.file_name() else '[No Name]')

Expand Down
8 changes: 2 additions & 6 deletions nv/ex_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -212,10 +212,6 @@ def _ex_route_edit(state) -> TokenCommand:
state.ignore()


def _ex_route_exit(state) -> TokenCommand:
return _create_route(state, 'exit')


def _ex_route_file(state) -> TokenCommand:
return _create_route(state, 'file')

Expand Down Expand Up @@ -760,7 +756,7 @@ def _add_ex_route(pattern: str, function, completions=None) -> None:
_add_ex_route(r'cq(?:uit)?', _ex_route_cquit, 'cquit')
_add_ex_route(r'delm(?:arks)?', _ex_route_delmarks, 'delmarks')
_add_ex_route(r'd(?:elete)?', _ex_route_delete, 'delete')
_add_ex_route(r'exi(?:t)?', _ex_route_exit, 'exit')
_add_ex_route(r'exi(?:t)?', _ex_route_wq, 'exit')
_add_ex_route(r'e(?:dit)?(?= |$)?', _ex_route_edit, 'edit')
_add_ex_route(r'f(?:ile)?', _ex_route_file, 'file')
_add_ex_route(r'g(?:lobal)?', _ex_route_global, 'global')
Expand Down Expand Up @@ -817,5 +813,5 @@ def _add_ex_route(pattern: str, function, completions=None) -> None:
_add_ex_route(r'xa(?:ll)?', _ex_route_wqall, 'xall')
_add_ex_route(r'xn(?:oremap)?', _ex_route_xnoremap, 'xnoremap')
_add_ex_route(r'xu(?:nmap)?', _ex_route_xunmap, 'xunmap')
_add_ex_route(r'x(?:it)?', _ex_route_exit, 'xit')
_add_ex_route(r'x(?:it)?', _ex_route_wq, 'xit')
_add_ex_route(r'y(?:ank)?', _ex_route_yank, 'yank')
3 changes: 1 addition & 2 deletions tests/nv/ex/test_scanner.py
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,6 @@ def cmd(*args, **kwargs):
self.assertCommand(['edit x/y.txt', 'e x/y.txt'], cmd('edit', params={'file_name': 'x/y.txt'})) # noqa: E501
self.assertCommand(['edit!', 'e!'], cmd('edit', params={'file_name': None}, forced=True)) # noqa: E501
self.assertCommand(['edit', 'e'], cmd('edit', params={'file_name': None})) # noqa: E501
self.assertCommand(['exit', 'exi', 'xit', 'x'], cmd('exit'))
self.assertCommand(['file', 'f'], cmd('file'))
self.assertCommand(['global!!x!y', 'g!!x!y'], cmd('global', params={'pattern': 'x', 'cmd': 'y'}, forced=True, addressable=True)) # noqa: E501
self.assertCommand(['global!/x/y', 'g!/x/y'], cmd('global', params={'pattern': 'x', 'cmd': 'y'}, forced=True, addressable=True)) # noqa: E501
Expand Down Expand Up @@ -647,7 +646,7 @@ def cmd(*args, **kwargs):
self.assertCommand(['wall!', 'wa!'], cmd('wall', forced=True))
self.assertCommand(['wall', 'wa'], cmd('wall'))
self.assertCommand(['wq!'], cmd('wq', forced=True))
self.assertCommand(['wq'], cmd('wq'))
self.assertCommand(['wq', 'exit', 'exi', 'xit', 'x'], cmd('wq'))
self.assertCommand(['wqall!', 'wqa!', 'xall!', 'xa!'], cmd('wqall', forced=True, addressable=True))
self.assertCommand(['wqall', 'wqa', 'xall', 'xa'], cmd('wqall', forced=False, addressable=True))
self.assertCommand(['wqall'], cmd('wqall', forced=False, addressable=True))
Expand Down
3 changes: 1 addition & 2 deletions tests/nv/test_ex_routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,6 @@ def test_valid_routes(self):
self.assertRoute('_ex_route_delete', ['delete', 'd'])
self.assertRoute('_ex_route_delmarks', ['delmarks', 'delm'])
self.assertRoute('_ex_route_edit', ['edit', 'e'])
self.assertRoute('_ex_route_exit', ['exit', 'exi', 'xit', 'x'])
self.assertRoute('_ex_route_file', ['file', 'f'])
self.assertRoute('_ex_route_global', ['global', 'g'])
self.assertRoute('_ex_route_help', ['help', 'h'])
Expand Down Expand Up @@ -309,7 +308,7 @@ def test_valid_routes(self):
self.assertRoute('_ex_route_vsplit', ['vsplit', 'vs'])
self.assertRoute('_ex_route_vunmap', ['vunmap', 'vu'])
self.assertRoute('_ex_route_wall', ['wall', 'wa'])
self.assertRoute('_ex_route_wq', ['wq'])
self.assertRoute('_ex_route_wq', ['wq', 'exit', 'exi', 'xit', 'x'])
self.assertRoute('_ex_route_wqall', ['wqall', 'wqa', 'xall', 'xa'])
self.assertRoute('_ex_route_write', ['write', 'w'])
self.assertRoute('_ex_route_xnoremap', ['xnoremap', 'xn'])
Expand Down

0 comments on commit 83ec805

Please sign in to comment.