| 1 |
let mapleader = '\' |
| 2 |
source plugin/jedi.vim |
| 3 |
source test/_utils.vim |
| 4 |
|
| 5 |
describe 'goto simple:' |
| 6 |
before |
| 7 |
new |
| 8 |
set filetype=python |
| 9 |
put =[ |
| 10 |
\ 'def a(): pass', |
| 11 |
\ 'b = a', |
| 12 |
\ 'c = b', |
| 13 |
\ ] |
| 14 |
normal! ggdd |
| 15 |
normal! G$ |
| 16 |
Expect line('.') == 3 |
| 17 |
end |
| 18 |
|
| 19 |
after |
| 20 |
bd! |
| 21 |
end |
| 22 |
|
| 23 |
it 'goto definitions' |
| 24 |
normal \d |
| 25 |
Expect line('.') == 2 |
| 26 |
Expect col('.') == 1 |
| 27 |
end |
| 28 |
|
| 29 |
it 'goto assignments' |
| 30 |
normal \g |
| 31 |
Expect line('.') == 2 |
| 32 |
Expect col('.') == 1 |
| 33 |
|
| 34 |
" cursor before `=` means that it stays there. |
| 35 |
normal \g |
| 36 |
Expect line('.') == 2 |
| 37 |
Expect col('.') == 1 |
| 38 |
|
| 39 |
" going to the last line changes it. |
| 40 |
normal! $ |
| 41 |
normal \g |
| 42 |
Expect line('.') == 1 |
| 43 |
Expect col('.') == 5 |
| 44 |
end |
| 45 |
end |
| 46 |
|
| 47 |
|
| 48 |
describe 'goto with tabs:' |
| 49 |
before |
| 50 |
set filetype=python |
| 51 |
let g:jedi#use_tabs_not_buffers = 1 |
| 52 |
end |
| 53 |
|
| 54 |
after |
| 55 |
try | %bwipeout! | catch | endtry |
| 56 |
end |
| 57 |
|
| 58 |
it 'follow import' |
| 59 |
put = ['import subprocess', 'subprocess'] |
| 60 |
normal G\g |
| 61 |
Expect getline('.') == 'import subprocess' |
| 62 |
Expect line('.') == 2 |
| 63 |
Expect col('.') == 8 |
| 64 |
|
| 65 |
normal G\d |
| 66 |
Expect CurrentBufferIsModule('subprocess') == 1 |
| 67 |
Expect line('.') == 1 |
| 68 |
Expect col('.') == 1 |
| 69 |
Expect tabpagenr('$') == 2 |
| 70 |
Expect winnr('$') == 1 |
| 71 |
bwipe |
| 72 |
|
| 73 |
Expect tabpagenr('$') == 1 |
| 74 |
Expect bufname('%') == '' |
| 75 |
end |
| 76 |
end |
| 77 |
|
| 78 |
|
| 79 |
describe 'goto with buffers' |
| 80 |
before |
| 81 |
set filetype=python |
| 82 |
let g:jedi#use_tabs_not_buffers = 0 |
| 83 |
end |
| 84 |
|
| 85 |
after |
| 86 |
try | %bwipeout! | catch | endtry |
| 87 |
set nohidden |
| 88 |
end |
| 89 |
|
| 90 |
it 'no new tabs' |
| 91 |
put = ['import os'] |
| 92 |
normal G$ |
| 93 |
call jedi#goto_assignments() |
| 94 |
python3 jedi_vim.goto() |
| 95 |
Expect CurrentBufferIsModule('os') == 0 |
| 96 |
" Without hidden, it's not possible to open a new buffer, when the old |
| 97 |
" one is not saved. |
| 98 |
set hidden |
| 99 |
call jedi#goto_assignments() |
| 100 |
Expect CurrentBufferIsModule('os') == 1 |
| 101 |
Expect winnr('$') == 1 |
| 102 |
Expect tabpagenr('$') == 1 |
| 103 |
Expect line('.') == 1 |
| 104 |
Expect col('.') == 1 |
| 105 |
end |
| 106 |
end |
| 107 |
|
| 108 |
|
| 109 |
|
| 110 |
describe 'goto with splits' |
| 111 |
before |
| 112 |
enew! |
| 113 |
set filetype=python |
| 114 |
let g:jedi#use_splits_not_buffers = 'left' |
| 115 |
end |
| 116 |
|
| 117 |
after |
| 118 |
try | %bwipeout! | catch | endtry |
| 119 |
end |
| 120 |
|
| 121 |
it 'follow import' |
| 122 |
put = ['import subprocess', 'subprocess'] |
| 123 |
normal G\g |
| 124 |
Expect getline('.') == 'import subprocess' |
| 125 |
Expect line('.') == 2 |
| 126 |
Expect col('.') == 8 |
| 127 |
|
| 128 |
normal G\d |
| 129 |
Expect CurrentBufferIsModule('subprocess') == 1 |
| 130 |
Expect line('.') == 1 |
| 131 |
Expect col('.') == 1 |
| 132 |
Expect winnr('$') == 2 |
| 133 |
wincmd l |
| 134 |
Expect bufname('%') == '' |
| 135 |
end |
| 136 |
|
| 137 |
end |
| 138 |
|
| 139 |
|
| 140 |
describe 'goto wildignore' |
| 141 |
before |
| 142 |
enew! |
| 143 |
set filetype=python |
| 144 |
set wildignore=*,with\ spaces,*.pyc |
| 145 |
set hidden |
| 146 |
let g:jedi#use_tag_stack = 1 |
| 147 |
let g:jedi#use_tabs_not_buffers = 0 |
| 148 |
" Need to use splits for code coverage in new_buffer() |
| 149 |
let g:jedi#use_splits_not_buffers = 1 |
| 150 |
|
| 151 |
put = ['from subprocess import Popen', 'Popen'] |
| 152 |
Expect CurrentBufferIsModule('subprocess') == 0 |
| 153 |
normal G |
| 154 |
end |
| 155 |
|
| 156 |
after |
| 157 |
try | %bwipeout! | catch | endtry |
| 158 |
set wildignore&vim |
| 159 |
end |
| 160 |
|
| 161 |
it 'restores wildignore' |
| 162 |
let before = &wildignore |
| 163 |
call jedi#goto() |
| 164 |
Expect getline('.') =~ 'Popen' |
| 165 |
Expect &wildignore == before |
| 166 |
end |
| 167 |
|
| 168 |
it 'not using tagstack' |
| 169 |
let g:jedi#use_tag_stack = 0 |
| 170 |
call jedi#goto() |
| 171 |
Expect CurrentBufferIsModule('subprocess') == 1 |
| 172 |
Expect getline('.') =~ 'Popen' |
| 173 |
end |
| 174 |
end |
| 175 |
|
| 176 |
|
| 177 |
" vim: et:ts=4:sw=4 |