So I wrote a small ulti-snips snippet with python interpolation. usually when you hit undo, after expanding the snippet, it goes back to trigger word. But in this case I have to hit the undo twice. I suspect it's the search function I am using. I would really appreciate some help on this. I would like to either use a better function than search or somehow use search (or whatever is causing this problem) to not pollute the undo history. Here is the snippet:
snippet super "Adds a super function for the current function" b
`!p
import vim
# get the class name
line_number = int(vim.eval('search("class .*(", "bn")'))
line = vim.current.buffer[line_number - 1]
class_name = re.findall(r'class\s+(.*?)\s*\(', line)[0]
# get the function signature
line_number = int(vim.eval('search("def.*self.*", "bn")'))
line = vim.current.buffer[line_number - 1]
func = re.findall(r'def\s+(.*):', line)[0]
matches = re.findall(r'(.*)\(self,?\s*(.*)\)', func)
snip.rv = 'super(%s, self).%s(%s)' % (class_name, matches[0][0], matches[0][1])
`
endsnippet