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

Error detected while processing TextChangedI Autocommands #1546

Closed
rickalex21 opened this issue Nov 12, 2023 · 7 comments
Closed

Error detected while processing TextChangedI Autocommands #1546

rickalex21 opened this issue Nov 12, 2023 · 7 comments

Comments

@rickalex21
Copy link

Expected behavior:
No errors

Actual behavior:

Error detected while processing TextChangedI Autocommands for "*"..function UltiSnips#TrackChange[1]..provide
r#python3#Call[18]..UltiSnips#TrackChange:
line 1:
:1: SyntaxWarning: invalid escape sequence '\e'
Press ENTER or type command to continue

@SirVer
Copy link
Owner

SirVer commented Nov 13, 2023

It sounds like you have a snippet with an invalid regular expression. Could that be?

Please provide a fully reproducible example, ideally using the approach explained in https://github.com/SirVer/ultisnips/blob/master/CONTRIBUTING.md#reproducing-bugs or if not possible with a minimal vimrc and snippets files and an exact sequence of key strokes that trigger the bug.

@SirVer SirVer added pending feedback triaged Bugs that I had a look at labels Nov 13, 2023
@rickalex21
Copy link
Author

@SirVer Hello, glad to see you're still on here maintaining. It's random, so that's going to be tricky
to reproduce but if I figure it out I will come back here and post. Just putting it out there to
see if anyone else is getting this error. Thanks

@rickalex21
Copy link
Author

rickalex21 commented Nov 18, 2023

@SirVer Was something changed recently in the code that is breaking plugins? Other plugins
like quangnguyen30192/cmp-nvim-ultisnips#80 are also experiencing issues.

From plugin cmp_nvim_ultisnips:

Error executing vim.schedule lua callback: function cmp_nvim_ultisnips#get_current_snippets[33]..provider#python3#Call, line 18: Vim(return):Error invoking 'python
_execute' on channel 8 (python3-script-host):                                                                                                                      
Traceback (most recent call last):                                                                                                                                 
  File "<string>", line 22, in <module>                                                                                                                            
  File "/usr/lib/python3.12/site-packages/pynvim/api/nvim.py", line 287, in command                                                                                
    return self.request('nvim_command', string, **kwargs)                                                                                                          
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                          
  File "/usr/lib/python3.12/site-packages/pynvim/api/nvim.py", line 182, in request                                                                                
    res = self._session.request(name, *args, **kwargs)                                                                                                             
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                             
  File "/usr/lib/python3.12/site-packages/pynvim/msgpack_rpc/session.py", line 102, in request                                                                     
    raise self.error_wrapper(err)                                                                                                                                  
pynvim.api.common.NvimError: Vim:<action-code>:1: SyntaxWarning: invalid escape sequence '\e'                                                                      
stack traceback:                                                                                                                                                   
        [C]: in function 'load_snippets'                                                                                                                           
        ...ged/cmp-nvim-ultisnips/lua/cmp_nvim_ultisnips/source.lua:27: in function 'complete'                                                                     
        ...ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/source.lua:334: in function 'complete'                                                                    
        ...e/ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/core.lua:299: in function 'complete'                                                                    
        ...e/ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/core.lua:169: in function 'autoindent'                                                                  
        ...e/ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/core.lua:161: in function 'on_change'                                                                   
        ...e/ritchie/.config/nvim/plugged/nvim-cmp/lua/cmp/init.lua:338: in function 'callback'                                                                    
        ...ie/.config/nvim/plugged/nvim-cmp/lua/cmp/utils/async.lua:165: in function <...ie/.config/nvim/plugged/nvim-cmp/lua/cmp/utils/async.lua:163>  

MINE

def expand_snip(snip):
	start,end = [snip.snippet_start,snip.snippet_end]
	print('start is ' , start, end, snip._start, snip._end)

	# methods_and_p = [method for method in dir(snip) if method.startswith('__') is False]
	# print("Methods and properties are.\n",methods_and_p)

	vim.eval('feedkeys("\<C-R>=UltiSnips#ExpandSnippet()\<CR>")')

@SirVer
Copy link
Owner

SirVer commented Nov 21, 2023

@rickalex21 This is almost certainly a bug in NVims Python emulation layer. You want to report it there, for me this is out of scope.

This issue was closed due to it only affecting Neovim and not core Vim.

Why is Neovim only best-effort?

UltiSnips maintenance is a lot of work. Reproducing bug reports is tedious, slow and error prone. The current maintainers have to limit their scope to provide a reasonable level of service to the community.

Neovim should work with any plugin that core vim works with. But in the past, Neovim support has been difficult for UltiSnips: It regularly had bugs that did not affect the core Vim distributions, i.e. Vim, gVim, MacVim, and Vim for Windows and its testing approach required a completely separate code path from core as well. Therefore, currently Neovim bugs are considered on a best effort basis.

UltiSnips is looking for an additional maintainer that is interested in bringing the Neovim level of service on par with core Vim. If you are interested in helping out, please reach out to SirVer.

@rickalex21
Copy link
Author

@SirVer I think I found the problem in my all.snippets, I wasn't having this problem before was there a change in the code somewhere?

Here is my global snippet, the problem is < in the FIXME:

def expand_snip(snip):
	start,end = [snip.snippet_start,snip.snippet_end]
	print('start is ' , start, end, snip._start, snip._end)

	# methods_and_p = [method for method in dir(snip) if method.startswith('__') is False]
	# print("Methods and properties are.\n",methods_and_p)

	#FIXME
	vim.eval('feedkeys("\<C-R>=UltiSnips#ExpandSnippet()\<CR>")')

Here is the other problem with the \e

# FIXME
post_jump "if snip.tabstop == 0: delCh('\e0xk')"
snippet modeline "Creates modelines"
$1`!p snip.rv=completion(t[1],'modeline')`$0
endsnippet

Here is the function delCh:

def delCh(move):
	#For when you need to delete a tabstop after completion.
	#Much better than calling del snip.buffer[linenr].
	vim.command(f'call feedkeys("{move}")')

@wookayin
Copy link
Contributor

wookayin commented Dec 12, 2023

delCh('\e0xk') or \e0xk is a valid python syntax and expression, and the post_jump directive seems also valid. Actually, I don't get a similar error with the same post_jump statement, the snippet worked OK for me. Please try to make a "self-contained" full reproduction which will help yourself troubleshoot the issue.

@ppwwyyxx
Copy link

ppwwyyxx commented Jul 12, 2024

	vim.eval('feedkeys("\<C-R>=UltiSnips#ExpandSnippet()\<CR>")')

\ should be replace by \\ (and similarly for other occurrences of \). Otherwise it produces a SyntaxWarning - this behavior is new in Python3.12 (see second bullet point of https://docs.python.org/3/whatsnew/3.12.html#other-language-changes ). This is not a neovim bug.

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

4 participants