]> Sergey Matveev's repositories - dotfiles.git/commitdiff
Rewrite testname on pure vimscript
authorSergey Matveev <stargrave@stargrave.org>
Mon, 13 Dec 2021 13:08:23 +0000 (16:08 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Thu, 27 Jan 2022 11:35:14 +0000 (14:35 +0300)
vim/.vim/pack/stargrave/start/py-testname/autoload/python/testname.vim

index 9cc598bf1a6d4d305eb7a190062f1eaccb2243bf..66610dc83321bdaeabe46cefb6caf76020865392 100644 (file)
@@ -7,16 +7,13 @@
 " copied to clipboard ("*) register.
 
 function! python#testname#get() abort
-    normal mm
-    normal ?.*\s*def .*[Tt]est\r
-    normal ^f(Byw
-    let postfix = @"
-    normal [[f(Byw
-    let postfix = @" . "." . postfix
-    normal `m
-    let base = join([""] + split(getcwd(), "/")[:-1], "/")
-    let prefix = substitute(expand("%:p:r")[len(base)+1:], "/", ".", "g")
-    let name = prefix . ":" . postfix
-    let @* = name
-    echomsg name
+    let l:pos = getpos(".")
+    let l:postfix = matchstr(getline(search(".*\s*def .*[Tt]est", "b")), '\w\+(')[:-2]
+    let l:postfix = matchstr(getline(search("^\s*class", "bn")), '\w\+(')[:-2] . "." . l:postfix
+    call setpos(".", l:pos)
+    let l:base = join([""] + split(getcwd(), "/")[:-1], "/")
+    let l:prefix = substitute(expand("%:p:r")[len(l:base)+1:], "/", ".", "g")
+    let l:name = l:prefix . ":" . l:postfix
+    let @* = l:name
+    echomsg l:name
 endfunction