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

Folding with zc enters visual mode. #366

Closed
hweom opened this issue Jul 7, 2018 · 13 comments
Closed

Folding with zc enters visual mode. #366

hweom opened this issue Jul 7, 2018 · 13 comments

Comments

@hweom
Copy link

hweom commented Jul 7, 2018

Description

When folding code with zc, editor folds the scope, but switches to visual mode at the same time.

myimage

Steps to Reproduce

Install NeoVintageous, add the following to the keyboard settings:

	{ "keys": ["z", "c"], "command": "fold" },
	{ "keys": ["z", "o"], "command": "unfold" },

Inside a code block, press z, a.

Expected behaviour

Folding without entering visual mode.

Actual behaviour

NeoVintageous enters visual mode after block folding.

Versions

Version 3.1.1 build 3176

Archlinux 64 bit.

Additional Information

@gerardroche
Copy link
Contributor

Try using NeoVintageous mappings. Sublime Text mappings won't work so well. See :h nv or https://github.com/NeoVintageous/NeoVintageous/blob/master/res/doc/neovintageous.txt.

Also maybe my mappings will help, I've played around with some folding mappings: https://github.com/gerardroche/sublimefiles/blob/master/User/.vintageousrc

@ghost
Copy link

ghost commented Jul 11, 2018

Then he would have the issue which relates to #308

Due to his key binding both starting with the same letter and muscle memory.

@gerardroche
Copy link
Contributor

@carlevison No I don't think that issue relates. The other issue is triggered when trying to map a single key like f and also use it as a prefix fb. Neo doesn't have the ability to trigger the first mapping after n secs, if no other key is pressed. There is no single key z command.

@hweom
Copy link
Author

hweom commented Jul 11, 2018

I've removed all entries from my .sublime-keymap and added the following to the .vintageousrc:

" Type :h vintageousrc for help.

" Folds
nnoremap zc :Fold<CR>
nnoremap zo :Unfold<CR>
nnoremap zM :FoldAll<CR>
nnoremap zR :UnfoldAll<CR>

But it still exhibits the same behavior.

@gerardroche
Copy link
Contributor

Make sure you reload your vintageousrc file via the Command Pallette: Reload My .vintageousrc File. Or try a restart.

@hweom
Copy link
Author

hweom commented Jul 11, 2018

Tried both. In fact, it's happening even if I fold with :Fold command.

Recorded some more examples with logs:

example1

example2

@gerardroche
Copy link
Contributor

gerardroche commented Jul 11, 2018

I can't reproduce it. When I close via zc my cursor is put on the first character at the start of the fold i.e. on the s of struct, and I'm in normal mode.

You can start Neo in debug mode for more logs, run sublime from command with the debug env variable set

$ SUBLIME_NEOVINTAGEOUS=t subl .

See https://github.com/NeoVintageous/NeoVintageous/blob/master/CONTRIBUTING.md.

@hweom
Copy link
Author

hweom commented Jul 12, 2018

Here is the log for folding with zc:

chr evt: z (0x7a)
command: _nv_feed_key {"key": "z"}
NeoVintageous: INFO    [cmds.py:281] key evt: z repeat_count=None do_eval=True check_user_mappings=True
NeoVintageous: DEBUG   [state.py:250] sequence >>>z<<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>>z<<<
NeoVintageous: DEBUG   [cmds.py:337] found incomplete mapping
NeoVintageous: DEBUG   [cmds.py:338] key evt took 0.0054s
chr evt: c (0x63)
command: _nv_feed_key {"key": "c"}
NeoVintageous: INFO    [cmds.py:281] key evt: c repeat_count=None do_eval=True check_user_mappings=True
NeoVintageous: DEBUG   [state.py:250] sequence >>>zc<<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>>zc<<<
NeoVintageous: DEBUG   [mappings.py:213] resolved None -> zc -> <NeoVintageous.nv.mappings.Mapping object at 0x7fcd00dae150>
NeoVintageous: DEBUG   [cmds.py:354] found user mapping...
NeoVintageous: DEBUG   [cmds.py:357] evaluating user mapping (mode=mode_normal)...
NeoVintageous: DEBUG   [state.py:250] sequence >>><<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>><<<
NeoVintageous: INFO    [cmds.py:370] user mapping zc -> :Fold<CR>
NeoVintageous: DEBUG   [ex_cmds.py:1730] do ex user cmdline >>>:Fold<CR><<<
NeoVintageous: DEBUG   [ex_cmds.py:1658] do ex cmdline >>>:Fold<<<
NeoVintageous: DEBUG   [ex_cmds.py:1673] execute user ex command: {'args': None, 'cmd': 'fold'}
NeoVintageous: DEBUG   [cmds.py:374] key evt took 0.0139s
chr evt: j (0x6a)
command: _nv_feed_key {"key": "j"}
NeoVintageous: INFO    [cmds.py:281] key evt: j repeat_count=None do_eval=True check_user_mappings=True
NeoVintageous: DEBUG   [state.py:250] sequence >>><<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>><<<
NeoVintageous: DEBUG   [state.py:250] sequence >>>j<<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>>j<<<
NeoVintageous: DEBUG   [mappings.py:213] resolved None -> j -> <ViMoveDownByLines (<unset>)>
NeoVintageous: INFO    [cmds.py:442] evaluating state...
NeoVintageous: INFO    [state.py:836] view.run_command() {'motion': '_vi_j', 'motion_args': {'count': 1, 'mode': 'mode_visual', 'xpos': 1}}
NeoVintageous: DEBUG   [state.py:250] sequence >>><<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>><<<
NeoVintageous: DEBUG   [cmds.py:445] key evt took 0.0113s
chr evt: j (0x6a)
command: _nv_feed_key {"key": "j"}
NeoVintageous: INFO    [cmds.py:281] key evt: j repeat_count=None do_eval=True check_user_mappings=True
NeoVintageous: DEBUG   [state.py:250] sequence >>>j<<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>>j<<<
NeoVintageous: DEBUG   [mappings.py:213] resolved None -> j -> <ViMoveDownByLines (<unset>)>
NeoVintageous: INFO    [cmds.py:442] evaluating state...
NeoVintageous: INFO    [state.py:836] view.run_command() {'motion': '_vi_j', 'motion_args': {'count': 1, 'mode': 'mode_visual', 'xpos': 1}}
NeoVintageous: DEBUG   [state.py:250] sequence >>><<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>><<<
NeoVintageous: DEBUG   [cmds.py:445] key evt took 0.0073s
chr evt: j (0x6a)
command: _nv_feed_key {"key": "j"}
NeoVintageous: INFO    [cmds.py:281] key evt: j repeat_count=None do_eval=True check_user_mappings=True
NeoVintageous: DEBUG   [state.py:250] sequence >>>j<<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>>j<<<
NeoVintageous: DEBUG   [mappings.py:213] resolved None -> j -> <ViMoveDownByLines (<unset>)>
NeoVintageous: INFO    [cmds.py:442] evaluating state...
NeoVintageous: INFO    [state.py:836] view.run_command() {'motion': '_vi_j', 'motion_args': {'count': 1, 'mode': 'mode_visual', 'xpos': 1}}
NeoVintageous: DEBUG   [state.py:250] sequence >>><<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>><<<
NeoVintageous: DEBUG   [cmds.py:445] key evt took 0.0077s
chr evt: j (0x6a)
command: _nv_feed_key {"key": "j"}
NeoVintageous: INFO    [cmds.py:281] key evt: j repeat_count=None do_eval=True check_user_mappings=True
NeoVintageous: DEBUG   [state.py:250] sequence >>>j<<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>>j<<<
NeoVintageous: DEBUG   [mappings.py:213] resolved None -> j -> <ViMoveDownByLines (<unset>)>
NeoVintageous: INFO    [cmds.py:442] evaluating state...
NeoVintageous: INFO    [state.py:836] view.run_command() {'motion': '_vi_j', 'motion_args': {'count': 1, 'mode': 'mode_visual', 'xpos': 1}}
NeoVintageous: DEBUG   [state.py:250] sequence >>><<<
NeoVintageous: DEBUG   [state.py:263] partial sequence >>><<<
NeoVintageous: DEBUG   [cmds.py:445] key evt took 0.0070s

@gerardroche
Copy link
Contributor

Everything looks good. It looks like the fold command is entering visual mode. I'm assuming it doesn't happen with commands like unfold.

My guess is that you have a rouge key binding or a plugin is overriding the fold command. Check your User directory for keymap files (Menu > Preferences > Borwse Packages... go to the User directory). Also look for any py files that probably shouldn't be there.

@hweom
Copy link
Author

hweom commented Jul 12, 2018

It does happen for unfolding with zo and :Unfold. Note that folding/unfolding by clicking the triangle left to the code block does not start the visual mode.

Here is the context of the User directory:

$ ls -a
 .                                'Package Control.merged-ca-bundle'
 ..                               'Package Control.sublime-settings'
'Default (Linux).sublime-keymap'  'Package Control.user-ca-bundle'
'Package Control.cache'            Preferences.sublime-settings
'Package Control.last-run'         .vintageousrc
$ cat Default\ \(Linux\).sublime-keymap 
[
]
$ cat .vintageousrc 
" Type :h vintageousrc for help.

" Folds
nnoremap zc :Fold<CR>
nnoremap zo :Unfold<CR>
nnoremap zM :FoldAll<CR>
nnoremap zR :UnfoldAll<CR>
$ cat Preferences.sublime-settings 
{
  "font_size": 11,
	"ensure_newline_at_eof_on_save": true,
	"ignored_packages":
	[
		"Six",
		"Vintage",
		"Vintageous"
	],
	"rulers":
	[
		80
	],
	"tab_size": 2,
	"translate_tabs_to_spaces": true,
	"vintageous_use_ctrl_keys": true
}
$ cat Package\ Control.sublime-settings 
{
	"bootstrapped": true,
	"in_process_packages":
	[
	],
	"installed_packages":
	[
		"NeoVintageous",
		"Package Control"
	],
	"repositories":
	[
	]
}

@ghost
Copy link

ghost commented Jul 26, 2018

After copying @hweom .vintageousrc file I can confirm I am experiencing the same issue that i'm being taken into VISUAL mode.

@gerardroche
Copy link
Contributor

Found it. Thanks.

The reason I couldn't reproduce it is because I have a custom fix to work around the issue:

https://github.com/gerardroche/sublimefiles/blob/983466569aeedd5455b74a73bbd15b22b27427a7/User/user_folds.py

There's no easy way for Neo to work around this issue. The fold commands themselves enter VISUAL mode. The workaround overrides the fold commands and fixes the cursor after fold commands are run. We can't really add this fix to Neo because overriding the default commands is a bit hacky.

@hweom
Copy link
Author

hweom commented Jul 31, 2018

The fold commands themselves enter VISUAL mode.

I don't know what part of original Sublime functionality these commands use. Just FYI, folding by clicking on the triangles right to the code blocks does not start VISUAL mode.

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