" test/ghost.vim -- regression test: ghost Tab-accept must not raise E565. " Headless: vim -u NONE -N -es -S test/ghost.vim (wired into `make check`) set nocompatible set rtp+=. source plugin/deepseek_fim.vim function! s:fail(name, expected, actual) abort call writefile(['FAIL ' . a:name . ': expected ' . string(a:expected) \ . ' actual ' . string(a:actual)], '/dev/stderr', 'a') cquit 1 endfunction function! s:check(actual, expected, name) abort if a:actual !=# a:expected call s:fail(a:name, a:expected, a:actual) endif endfunction enew! " --- helpers needed by the ghost path exist ------------------------------- call s:check(exists('*deepseek_fim#insert_at'), 1, 'insert_at exists') call s:check(exists('*deepseek_fim#tab'), 1, 'tab exists') " --- no ghost: Tab falls back to a real Tab, buffer untouched ----------- call setline(1, 'def fib(a):') call cursor(1, 12) call s:check(deepseek_fim#has_ghost(), 0, 'no ghost initially') call s:check(deepseek_fim#accept(), 0, 'accept without ghost returns 0') call s:check(deepseek_fim#tab(), "\", 'tab falls back to real Tab') call s:check(getline(1), 'def fib(a):', 'tab() leaves buffer untouched') " --- single-line insert at end of line ----------------------------------- call setline(1, 'def fib(a):') call s:check(deepseek_fim#insert_at(1, 12, ' + 1'), 1, 'single-line returns 1') call s:check(getline(1), 'def fib(a): + 1', 'single-line text') " cursor() klemt af op het laatste teken; de via feedkeys (die de " cursor er in insert-mode achter zet) is pas na terugkeer zichtbaar. call s:check([line('.'), col('.')], [1, 15], 'single-line cursor (pre-Right)') " --- two-part insert mid-line -------------------------------------------- call setline(1, 'a()') call s:check(deepseek_fim#insert_at(1, 3, "x,\ny"), 1, 'two-part returns 1') call s:check(getline(1), 'a(x,', 'two-part first line') call s:check(getline(2), 'y)', 'two-part second line') call s:check([line('.'), col('.')], [2, 2], 'two-part cursor') " --- three-part insert mid-line ------------------------------------------- call setline(1, 'ab') call s:check(deepseek_fim#insert_at(1, 2, "X\nY\nZ"), 1, 'three-part returns 1') call s:check(getline(1), 'aX', 'three-part line 1') call s:check(getline(2), 'Y', 'three-part line 2') call s:check(getline(3), 'Zb', 'three-part line 3') call s:check([line('.'), col('.')], [3, 2], 'three-part cursor') " --- guards ---------------------------------------------------------------- call s:check(deepseek_fim#insert_at(99, 1, 'x'), 0, 'out-of-range row rejected') " --- insert-mode Tab mapping routes through tab() -------------------------- call s:check(maparg('', 'i') =~# 'deepseek_fim#tab()', 1, 'Tab mapping calls tab()') qa!