mirror of
https://github.com/SpaceVim/SpaceVim.git
synced 2025-01-23 07:20:04 +08:00
chore(bundle): update bundle clever-f
This commit is contained in:
parent
e7344bab8b
commit
9a21254747
@ -10,6 +10,7 @@ In `bundle/` directory, there are two kinds of plugins: forked plugins without c
|
||||
- `neoformat`: based on [neoformat](https://github.com/sbdchd/neoformat/tree/f1b6cd506b72be0a2aaf529105320ec929683920)
|
||||
- `github-issues.vim`: based on [github-issues.vim](https://github.com/jaxbot/github-issues.vim/tree/46f1922d3d225ed659f3dda1c95e35001c9f41f4)
|
||||
- `vim-virtualenv`: based on [vim-virtualenv](https://github.com/jmcantrell/vim-virtualenv/tree/b1150223cd876f155ed7a3b2e285ed33f6f93873)
|
||||
- `clever-f.vim`: based on [`clever-f.vim@fd370f2`](https://github.com/rhysd/clever-f.vim/tree/fd370f27cca93918184a8043220cef1aa440a1fd)
|
||||
|
||||
### No changed plugins
|
||||
|
||||
|
24
bundle/clever-f.vim/.github/workflows/ci.yml
vendored
24
bundle/clever-f.vim/.github/workflows/ci.yml
vendored
@ -27,40 +27,48 @@ jobs:
|
||||
PROFILE_LOG: profile.txt
|
||||
run: |
|
||||
cd ./test
|
||||
echo $THEMIS_VIM
|
||||
echo "${THEMIS_VIM}"
|
||||
../vim-themis/bin/themis .
|
||||
# covimerage seems not maintained for Windows. Skip taking code coverage on Windows
|
||||
- name: Install Python
|
||||
if: matrix.os != 'windows-latest'
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
uses: actions/setup-python@v1
|
||||
- name: Install covimerage
|
||||
if: matrix.os != 'windows-latest'
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
run: |
|
||||
# https://github.com/Vimjas/covimerage/issues/95
|
||||
pip install 'click<8.0.0'
|
||||
pip install covimerage
|
||||
covimerage --version
|
||||
- name: Run covimerage
|
||||
if: matrix.os != 'windows-latest'
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
run: |
|
||||
cd ./test
|
||||
covimerage write_coverage profile.txt
|
||||
- name: Take coverage
|
||||
if: matrix.os != 'windows-latest'
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
run: |
|
||||
cd ./test
|
||||
coverage report
|
||||
coverage xml
|
||||
- name: Upload coverage to codecov
|
||||
if: matrix.os != 'windows-latest'
|
||||
if: ${{ matrix.os != 'windows-latest' }}
|
||||
uses: codecov/codecov-action@v1
|
||||
with:
|
||||
token: ${{ secrets.CODECOV_TOKEN }}
|
||||
file: ./test/coverage.xml
|
||||
|
||||
vint:
|
||||
name: Run vint
|
||||
lint:
|
||||
name: Lint
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/setup-python@v1
|
||||
- run: pip install vim-vint
|
||||
- run: vint --warning --verbose --enable-neovim ./autoload ./plugin
|
||||
- run: sudo apt install shellcheck
|
||||
- name: Run actionlint
|
||||
run: |
|
||||
bash <(curl https://raw.githubusercontent.com/rhysd/actionlint/main/scripts/download-actionlint.bash)
|
||||
./actionlint -color
|
||||
shell: bash
|
||||
|
33
bundle/clever-f.vim/.github/workflows/weekly.yml
vendored
Normal file
33
bundle/clever-f.vim/.github/workflows/weekly.yml
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
name: Weekly check
|
||||
on:
|
||||
schedule:
|
||||
- cron: '0 0 * * 0'
|
||||
|
||||
jobs:
|
||||
unit-tests:
|
||||
name: Unit tests
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-latest, macos-latest, windows-latest]
|
||||
neovim: [false, true]
|
||||
runs-on: ${{ matrix.os }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- name: Checkout themis.vim
|
||||
uses: actions/checkout@v2
|
||||
with:
|
||||
repository: thinca/vim-themis
|
||||
path: vim-themis
|
||||
- name: Install Vim or Neovim
|
||||
uses: rhysd/action-setup-vim@v1
|
||||
id: vim
|
||||
with:
|
||||
neovim: ${{ matrix.neovim }}
|
||||
- name: Run unit tests
|
||||
env:
|
||||
THEMIS_VIM: ${{ steps.vim.outputs.executable }}
|
||||
PROFILE_LOG: profile.txt
|
||||
run: |
|
||||
cd ./test
|
||||
echo "$THEMIS_VIM"
|
||||
../vim-themis/bin/themis .
|
@ -19,7 +19,7 @@ Lastly, you can customize the behavior of the mappings and features.
|
||||
|
||||
## USAGE
|
||||
|
||||
![Screen shot](https://raw.githubusercontent.com/rhysd/screenshots/master/clever-f.vim/cleverf_main.gif)
|
||||
![Screen shot](https://raw.githubusercontent.com/rhysd/ss/master/clever-f.vim/cleverf_main.gif)
|
||||
|
||||
I'll show some examples of usage. `_` is the place of cursor, `->` is a move of cursor, alphabets above
|
||||
`->` is input by keyboard. Note that this is a part of clever-f.vim's features.
|
||||
@ -32,7 +32,7 @@ I'll show some examples of usage. `_` is the place of cursor, `->` is a move of
|
||||
move : _<-----------------------------_<-_
|
||||
text : hoge huga hoo hugu ponyo
|
||||
|
||||
![f screencast](https://raw.githubusercontent.com/rhysd/screenshots/master/clever-f.vim/cleverf_1.gif)
|
||||
![f screencast](https://raw.githubusercontent.com/rhysd/ss/master/clever-f.vim/cleverf_1.gif)
|
||||
|
||||
|
||||
### __`F`__
|
||||
@ -43,7 +43,7 @@ I'll show some examples of usage. `_` is the place of cursor, `->` is a move of
|
||||
move : _---------->_------>_----------->_
|
||||
text : hoge huga huyo hugu ponyo
|
||||
|
||||
![F screencast](https://raw.githubusercontent.com/rhysd/screenshots/master/clever-f.vim/cleverf_2.gif)
|
||||
![F screencast](https://raw.githubusercontent.com/rhysd/ss/master/clever-f.vim/cleverf_2.gif)
|
||||
|
||||
|
||||
### __`t`__
|
||||
@ -54,7 +54,7 @@ I'll show some examples of usage. `_` is the place of cursor, `->` is a move of
|
||||
move : _<-----------------------------__
|
||||
text : hoge huga hoo hugu ponyo
|
||||
|
||||
![t screencast](https://raw.githubusercontent.com/rhysd/screenshots/master/clever-f.vim/cleverf_3.gif)
|
||||
![t screencast](https://raw.githubusercontent.com/rhysd/ss/master/clever-f.vim/cleverf_3.gif)
|
||||
|
||||
|
||||
## CUSTOMIZE
|
||||
@ -71,7 +71,9 @@ to be case-insensitive, set it to `1` in your vimrc.
|
||||
|
||||
### Smart case
|
||||
|
||||
`g:clever_f_smart_case` controls whether searches are smart case or not. If you type a lower case character, the case will be ignored however if you type an upper case character it will only search for upper case characters. Please set it to `1` in your vimrc to enable searching by smart case.
|
||||
`g:clever_f_smart_case` controls whether searches are smart case or not. If you type a lower case character,
|
||||
the case will be ignored however if you type an upper case character it will only search for upper case characters.
|
||||
Please set it to `1` in your vimrc to enable searching by smart case.
|
||||
|
||||
### Target character highlighting in current line
|
||||
|
||||
@ -81,18 +83,41 @@ group to `g:clever_f_mark_char_color`.
|
||||
|
||||
Below is an example using `ta` in description of clever-f.vim.
|
||||
|
||||
![highlight example](https://raw.githubusercontent.com/rhysd/screenshots/master/clever-f.vim/cleverf_4.gif)
|
||||
![highlight example](https://raw.githubusercontent.com/rhysd/ss/master/clever-f.vim/cleverf_4.gif)
|
||||
|
||||
Here, `ta` searches `a` forward then matches the character before `a` and `Ta` searches `a` backward
|
||||
then matches the character after `a`. You can see the highlighted target is dynamically changed following
|
||||
the cursor's direction.
|
||||
|
||||
### Timeout
|
||||
Highlight can be cleared after timeout. See below section.
|
||||
|
||||
You can specify the timeout for `f`, `F`, `t` and `T` mappings. If the interval of these mappings
|
||||
is greater than the one you specified, clever-f.vim resets its state to make you input a new character.
|
||||
This feature is disabled by default. If you want to use this feature, set `g:clever_f_timeout_ms`
|
||||
to proper value.
|
||||
### Highlighting characters which can be directly jumped to
|
||||
|
||||
clever-f.vim can highlight the characters in the line which can be directly jumped to. With this feature, you
|
||||
can easily understand where cursor can move by the `f{char}` input before inputting `{char}`.
|
||||
|
||||
For example, when 'aba' is in the current line, cursor can reach the first 'a' with `fa` but cannot reach the second 'a'.
|
||||
In this case, the first 'a' is highlighted but the second 'a' is not when typing `f`.
|
||||
|
||||
To enable this feature, set `1` to `g:clever_f_mark_direct` in your vimrc. Note that setting `1` after Vim
|
||||
starts does not work.
|
||||
|
||||
### Repeat timeout
|
||||
|
||||
You can specify the timeout for repeating the previous target character on `f`, `F`, `t` and `T` mappings.
|
||||
If the interval of these mappings is greater than the one you specified, clever-f.vim resets its state to make you
|
||||
input a new character. This feature is disabled by default. If you want to use this feature, set timeout value in
|
||||
milliseconds to `g:clever_f_timeout_ms`.
|
||||
|
||||
### Highlight timeout
|
||||
|
||||
When target character highlighting is enabled, the highlight can be cleared after specific timeout.
|
||||
|
||||
By default, this feature is not enabled. Highlight won't be cleared until the cursor moves. To enable this feature,
|
||||
set milliseconds value to `g:clever_f_highlight_timeout_ms`.
|
||||
|
||||
This feature requires timer feature added at Vim8. Confirm `:echo has('timers')` returns `1` to check if this feature
|
||||
is available.
|
||||
|
||||
### Repeat last input
|
||||
|
||||
|
@ -3,6 +3,8 @@ set cpo&vim
|
||||
|
||||
" constants
|
||||
let s:ON_NVIM = has('nvim')
|
||||
let s:ESC_CODE = char2nr("\<Esc>")
|
||||
let s:HAS_TIMER = has('timers')
|
||||
|
||||
" configurations
|
||||
let g:clever_f_across_no_line = get(g:, 'clever_f_across_no_line', 0)
|
||||
@ -18,6 +20,7 @@ let g:clever_f_timeout_ms = get(g:, 'clever_f_timeout_ms', 0)
|
||||
let g:clever_f_mark_char = get(g:, 'clever_f_mark_char', 1)
|
||||
let g:clever_f_repeat_last_char_inputs = get(g:, 'clever_f_repeat_last_char_inputs', ["\<CR>"])
|
||||
let g:clever_f_mark_direct = get(g:, 'clever_f_mark_direct', 0)
|
||||
let g:clever_f_highlight_timeout_ms = get(g:, 'clever_f_highlight_timeout_ms', 0)
|
||||
|
||||
" below variable must be set before loading this script
|
||||
let g:clever_f_clean_labels_eagerly = get(g:, 'clever_f_clean_labels_eagerly', 1)
|
||||
@ -75,6 +78,7 @@ let s:first_move = {}
|
||||
let s:migemo_dicts = {}
|
||||
let s:previous_char_num = {}
|
||||
let s:timestamp = [0, 0]
|
||||
let s:highlight_timer = -1
|
||||
|
||||
" keys are mode string returned from mode()
|
||||
function! clever_f#reset() abort
|
||||
@ -99,11 +103,13 @@ function! clever_f#_reset_all() abort
|
||||
let s:previous_char_num = {}
|
||||
autocmd! plugin-clever-f-finalizer
|
||||
unlet! s:moved_forward
|
||||
|
||||
return ''
|
||||
endfunction
|
||||
|
||||
function! s:remove_highlight() abort
|
||||
if s:highlight_timer >= 0
|
||||
call timer_stop(s:highlight_timer)
|
||||
let s:highlight_timer = -1
|
||||
endif
|
||||
for h in filter(getmatches(), 'v:val.group ==# "CleverFChar"')
|
||||
call matchdelete(h.id)
|
||||
endfor
|
||||
@ -117,12 +123,21 @@ function! s:is_timedout() abort
|
||||
return elapsed_ms > g:clever_f_timeout_ms
|
||||
endfunction
|
||||
|
||||
function! s:on_highlight_timer_expired(timer) abort
|
||||
if s:highlight_timer != a:timer
|
||||
return
|
||||
endif
|
||||
let s:highlight_timer = -1
|
||||
call s:remove_highlight()
|
||||
endfunction
|
||||
|
||||
" highlight characters to which the cursor can be moved directly
|
||||
function! s:mark_direct(forward, count) abort
|
||||
" Note: public function for test
|
||||
function! clever_f#_mark_direct(forward, count) abort
|
||||
let line = getline('.')
|
||||
let [_, l, c, _] = getpos('.')
|
||||
|
||||
if (a:forward && c == len(line)) || (!a:forward && c == 1)
|
||||
if (a:forward && c >= len(line)) || (!a:forward && c == 1)
|
||||
" there is no matching characters
|
||||
return []
|
||||
endif
|
||||
@ -157,11 +172,6 @@ function! s:mark_direct(forward, count) abort
|
||||
return matches
|
||||
endfunction
|
||||
|
||||
" introduce public function for test
|
||||
function! clever_f#_mark_direct(forward, count) abort
|
||||
return s:mark_direct(a:forward, a:count)
|
||||
endfunction
|
||||
|
||||
function! s:mark_char_in_current_line(map, char) abort
|
||||
let regex = '\%' . line('.') . 'l' . s:generate_pattern(a:map, a:char)
|
||||
call matchadd('CleverFChar', regex , 999)
|
||||
@ -185,7 +195,7 @@ endfunction
|
||||
|
||||
function! clever_f#find_with(map) abort
|
||||
if a:map !~# '^[fFtT]$'
|
||||
throw "Error: Invalid mapping '" . a:map . "'"
|
||||
throw "clever-f: Invalid mapping '" . a:map . "'"
|
||||
endif
|
||||
|
||||
if &foldopen =~# '\<\%(all\|hor\)\>'
|
||||
@ -195,13 +205,20 @@ function! clever_f#find_with(map) abort
|
||||
endif
|
||||
|
||||
let current_pos = getpos('.')[1 : 2]
|
||||
|
||||
let mode = s:mode()
|
||||
if current_pos != get(s:previous_pos, mode, [0, 0])
|
||||
let highlight_timer_enabled = g:clever_f_mark_char && g:clever_f_highlight_timeout_ms > 0 && s:HAS_TIMER
|
||||
let in_macro = clever_f#compat#reg_executing() !=# ''
|
||||
|
||||
" When 'f' is run while executing a macro, do not repeat previous
|
||||
" character. See #59 for more details
|
||||
if current_pos != get(s:previous_pos, mode, [0, 0]) || in_macro
|
||||
let should_redraw = !in_macro
|
||||
let back = 0
|
||||
if g:clever_f_mark_cursor
|
||||
let cursor_marker = matchadd('CleverFCursor', '\%#', 999)
|
||||
redraw
|
||||
if should_redraw
|
||||
redraw
|
||||
endif
|
||||
endif
|
||||
" block-NONE does not work on Neovim
|
||||
if g:clever_f_hide_cursor_on_cmdline && !s:ON_NVIM
|
||||
@ -211,15 +228,17 @@ function! clever_f#find_with(map) abort
|
||||
set t_ve=
|
||||
endif
|
||||
try
|
||||
if g:clever_f_mark_direct
|
||||
let direct_markers = s:mark_direct(a:map =~# '\l', v:count1)
|
||||
if g:clever_f_mark_direct && should_redraw
|
||||
let direct_markers = clever_f#_mark_direct(a:map =~# '\l', v:count1)
|
||||
redraw
|
||||
endif
|
||||
if g:clever_f_show_prompt | echon 'clever-f: ' | endif
|
||||
if g:clever_f_show_prompt
|
||||
echon 'clever-f: '
|
||||
endif
|
||||
let s:previous_map[mode] = a:map
|
||||
let s:first_move[mode] = 1
|
||||
let cn = s:getchar()
|
||||
if cn == char2nr("\<Esc>")
|
||||
if cn == s:ESC_CODE
|
||||
return "\<Esc>"
|
||||
endif
|
||||
if index(map(deepcopy(g:clever_f_repeat_last_char_inputs), 'char2nr(v:val)'), cn) == -1
|
||||
@ -250,10 +269,12 @@ function! clever_f#find_with(map) abort
|
||||
endif
|
||||
endif
|
||||
|
||||
if g:clever_f_show_prompt | redraw! | endif
|
||||
if g:clever_f_show_prompt && should_redraw
|
||||
redraw!
|
||||
endif
|
||||
finally
|
||||
if g:clever_f_mark_cursor | call matchdelete(cursor_marker) | endif
|
||||
if g:clever_f_mark_direct
|
||||
if g:clever_f_mark_direct && exists('l:direct_markers')
|
||||
for m in direct_markers
|
||||
call matchdelete(m)
|
||||
endfor
|
||||
@ -271,10 +292,11 @@ function! clever_f#find_with(map) abort
|
||||
endif
|
||||
endtry
|
||||
else
|
||||
" when repeated
|
||||
" When repeated
|
||||
|
||||
let back = a:map =~# '\u'
|
||||
if g:clever_f_fix_key_direction
|
||||
let back = s:previous_map[mode] =~# '\u' ? !back : back
|
||||
if g:clever_f_fix_key_direction && s:previous_map[mode] =~# '\u'
|
||||
let back = !back
|
||||
endif
|
||||
|
||||
" reset and retry if timed out
|
||||
@ -282,6 +304,22 @@ function! clever_f#find_with(map) abort
|
||||
call clever_f#reset()
|
||||
return clever_f#find_with(a:map)
|
||||
endif
|
||||
|
||||
" Restore highlights which were removed by timeout
|
||||
if highlight_timer_enabled && s:highlight_timer < 0
|
||||
call s:remove_highlight()
|
||||
if mode ==# 'n' || mode ==? 'v' || mode ==# "\<C-v>" ||
|
||||
\ mode ==# 'ce' || mode ==? 's' || mode ==# "\<C-s>"
|
||||
call s:mark_char_in_current_line(s:previous_map[mode], s:previous_char_num[mode])
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
if highlight_timer_enabled
|
||||
if s:highlight_timer >= 0
|
||||
call timer_stop(s:highlight_timer)
|
||||
endif
|
||||
let s:highlight_timer = timer_start(g:clever_f_highlight_timeout_ms, funcref('s:on_highlight_timer_expired'))
|
||||
endif
|
||||
|
||||
return clever_f#repeat(back)
|
||||
@ -412,7 +450,7 @@ function! s:load_migemo_dict() abort
|
||||
return clever_f#migemo#eucjp#load_dict()
|
||||
else
|
||||
let g:clever_f_use_migemo = 0
|
||||
throw 'Error: ' . enc . ' is not supported. Migemo is disabled.'
|
||||
throw "clever-f: Encoding '" . enc . "' is not supported. Migemo is disabled"
|
||||
endif
|
||||
endfunction
|
||||
|
||||
|
@ -17,3 +17,14 @@ else
|
||||
return a:a && !a:b || !a:a && a:b
|
||||
endfunction
|
||||
endif
|
||||
|
||||
if exists('*reg_executing')
|
||||
function! clever_f#compat#reg_executing() abort
|
||||
return reg_executing()
|
||||
endfunction
|
||||
else
|
||||
" reg_executing() was introduced at Vim 8.2.0020 and Neovim 0.4.0
|
||||
function! clever_f#compat#reg_executing() abort
|
||||
return ''
|
||||
endfunction
|
||||
endif
|
||||
|
@ -174,6 +174,13 @@ g:clever_f_timeout_ms *g:clever_f_timeout_ms*
|
||||
value is millisecond.
|
||||
The default value is 0 (it means no timeout).
|
||||
|
||||
g:clever_f_highlight_timeout_ms *g:clever_f_highlight_timeout_ms*
|
||||
|
||||
Setting a number value to this variable specifies the timeout for clearing
|
||||
highlights in milliseconds. When the value is greater than 0, highlights
|
||||
on the target character are automatically cleared after the timeout.
|
||||
The default value is 0 (it means no timeout).
|
||||
|
||||
g:clever_f_mark_char *g:clever_f_mark_char*
|
||||
|
||||
If the value is equivalent to 1, the characters in line which you input
|
||||
@ -214,6 +221,10 @@ g:clever_f_mark_direct *g:clever_f_mark_direct*
|
||||
is enabled in normal and visual mode.
|
||||
The default value is 0.
|
||||
|
||||
Note:
|
||||
|g:clever_f_mark_direct| must be set before |clever-f| is loaded. Setting
|
||||
to 1 in your |vimrc| is recommended.
|
||||
|
||||
g:clever_f_mark_direct_color *g:clever_f_mark_direct_color*
|
||||
|
||||
If |g:clever_f_mark_direct| is enabled, |clever-f| highlights characters
|
||||
|
@ -1,8 +1,8 @@
|
||||
## How to execute tests
|
||||
|
||||
It requires [vim-themis](https://github.com/thinca/vim-themis). You need to install it in advance.
|
||||
[vim-themis](https://github.com/thinca/vim-themis) is required.
|
||||
|
||||
For example, following clones it locally in clever-f.vim repository.
|
||||
For example, the following clones it locally in clever-f.vim repository.
|
||||
|
||||
```console
|
||||
$ cd /path/to/clever-f.vim/test
|
||||
@ -12,9 +12,13 @@ $ ./vim-themis/bin/themis .
|
||||
|
||||
## How to measure code coverage
|
||||
|
||||
It requires [covimerage](https://github.com/Vimjas/covimerage).
|
||||
[covimerage](https://github.com/Vimjas/covimerage) is required. I recommend to use
|
||||
[venv](https://docs.python.org/3/library/venv.html) for installing it locally.
|
||||
|
||||
```console
|
||||
$ python -m venv venv
|
||||
$ source ./venv/bin/activate
|
||||
|
||||
$ pip install covimerage
|
||||
$ cd /path/to/clever-f.vim/test
|
||||
|
||||
@ -33,6 +37,6 @@ $ coverage html
|
||||
|
||||
## CI
|
||||
|
||||
CI is run in both Linux and macOS using Travis CI: https://travis-ci.org/rhysd/clever-f.vim
|
||||
CI runs on Linux, macOS and Windows using GitHub Actions: https://github.com/rhysd/clever-f.vim/actions?query=workflow%3ACI
|
||||
|
||||
Coverage is tracked with codecov.io: https://codecov.io/gh/rhysd/clever-f.vim
|
||||
|
@ -12,6 +12,22 @@ function! CursorPos()
|
||||
return [line('.'), col('.'), getline('.')[col('.')-1]]
|
||||
endfunction
|
||||
|
||||
function! Highlights() abort
|
||||
return filter(getmatches(), 'v:val.group==#"CleverFChar"')
|
||||
endfunction
|
||||
|
||||
function! WaitUntil(ms, pred) abort
|
||||
let remaining = a:ms
|
||||
while remaining > 0
|
||||
sleep 10m
|
||||
let remaining -= 10
|
||||
if a:pred()
|
||||
return 1
|
||||
endif
|
||||
endwhile
|
||||
return 0
|
||||
endfunction
|
||||
|
||||
Describe default config
|
||||
It should load plugin
|
||||
Assert g:loaded_clever_f
|
||||
@ -274,7 +290,7 @@ Describe f, F, t and T mappings
|
||||
Assert Equals(getline('.'), "piyo poyo")
|
||||
Assert Equals(CursorPos(), [l, 2, 'i'])
|
||||
|
||||
normal! dfp
|
||||
normal dfp
|
||||
Assert Equals(getline('.'), "poyo")
|
||||
Assert Equals(CursorPos(), [l, 2, 'o'])
|
||||
End
|
||||
@ -311,9 +327,50 @@ Describe f, F, t and T mappings
|
||||
normal fo
|
||||
Assert Equals(CursorPos(), [l,14,'o'])
|
||||
End
|
||||
|
||||
It should work while running in macro
|
||||
for _ in range(10)
|
||||
call AddLine('poge huga hiyo poyo')
|
||||
endfor
|
||||
normal! gg0
|
||||
|
||||
" Macro to change the line from 'poge huga hiyo poyo' to 'poge'
|
||||
let @a = 'thDj'
|
||||
normal 10@a
|
||||
|
||||
for l in range(2, 10)
|
||||
Assert Equals(getline(l), 'poge')
|
||||
endfor
|
||||
End
|
||||
|
||||
It should not repeat previous character while running in macro (#59)
|
||||
call AddLine('1a 2a 3a 4a 5a')
|
||||
normal! gg0
|
||||
let @a = 'fax'
|
||||
normal 5@a
|
||||
Assert Equals(getline('.'), '1 2 3 4 5')
|
||||
End
|
||||
|
||||
It should share its state among mappings
|
||||
normal! 0
|
||||
let l = line('.')
|
||||
let left = [l, 6, 'h']
|
||||
let right = [l, 11, 'h']
|
||||
|
||||
normal fh
|
||||
Assert Equals(CursorPos(), left)
|
||||
normal f
|
||||
Assert Equals(CursorPos(), right)
|
||||
normal F
|
||||
Assert Equals(CursorPos(), left)
|
||||
normal t
|
||||
Assert Equals(CursorPos(), right)
|
||||
normal T
|
||||
Assert Equals(CursorPos(), left)
|
||||
End
|
||||
End
|
||||
|
||||
Describe f and F mappings' contexts
|
||||
Describe clever_f#reset()
|
||||
Before
|
||||
new
|
||||
call clever_f#reset()
|
||||
@ -324,18 +381,32 @@ Describe f and F mappings' contexts
|
||||
close!
|
||||
End
|
||||
|
||||
It should be shared
|
||||
It should reset current target character
|
||||
normal! 0
|
||||
let l = line('.')
|
||||
|
||||
normal fh
|
||||
Assert Equals(CursorPos(), [l,6,'h'])
|
||||
normal f
|
||||
Assert Equals(CursorPos(), [l,11,'h'])
|
||||
normal F
|
||||
call clever_f#reset()
|
||||
normal to
|
||||
Assert Equals(CursorPos(), [l,13,'y'])
|
||||
End
|
||||
|
||||
It should be called on <Plug>(clever-f-reset)
|
||||
normal! 0
|
||||
let l = line('.')
|
||||
normal fh
|
||||
Assert Equals(CursorPos(), [l,6,'h'])
|
||||
normal f
|
||||
Assert Equals(CursorPos(), [l,11,'h'])
|
||||
execute 'normal' "\<Plug>(clever-f-reset)"
|
||||
normal to
|
||||
Assert Equals(CursorPos(), [l,13,'y'])
|
||||
End
|
||||
|
||||
It should remove target highlights
|
||||
normal! 0
|
||||
normal fhff
|
||||
Assert NotEquals(Highlights(), [])
|
||||
call clever_f#reset()
|
||||
Assert Equals(Highlights(), [])
|
||||
End
|
||||
End
|
||||
|
||||
@ -499,7 +570,7 @@ Context Multibyte characters
|
||||
End
|
||||
End
|
||||
|
||||
describe g:clever_f_ignore_case
|
||||
Describe g:clever_f_ignore_case
|
||||
Before
|
||||
new
|
||||
let g:clever_f_ignore_case = 1
|
||||
@ -557,7 +628,7 @@ End
|
||||
|
||||
Describe clever_f#find_with()
|
||||
It should raise an error when invalid map is given
|
||||
Throws /Error: Invalid mapping/ clever_f#find_with('x')
|
||||
Throws /^clever-f: Invalid mapping/ clever_f#find_with('x')
|
||||
End
|
||||
End
|
||||
|
||||
@ -746,6 +817,15 @@ Describe <Esc>
|
||||
execute 'normal' "f\<Esc>"
|
||||
Assert Equals(len(filter(getmatches(), 'v:val.group==#"CleverFDirect"')), 0)
|
||||
End
|
||||
|
||||
It does nothing on empty line (#55)
|
||||
call AddLine('')
|
||||
normal! G0
|
||||
Assert Equals(getline('.'), '')
|
||||
Assert Equals(col('.'), 1)
|
||||
normal fa
|
||||
Assert Equals(col('.'), 1)
|
||||
End
|
||||
End
|
||||
End
|
||||
|
||||
@ -931,6 +1011,7 @@ End
|
||||
Describe g:clever_f_mark_char
|
||||
Before
|
||||
new
|
||||
let saved_mark_char = g:clever_f_mark_char
|
||||
let g:clever_f_mark_char = 1
|
||||
call clever_f#reset()
|
||||
call AddLine('poge huga hiyo poyo')
|
||||
@ -941,30 +1022,31 @@ Describe g:clever_f_mark_char
|
||||
After
|
||||
close!
|
||||
let g:clever_f_across_no_line = old_across_no_line
|
||||
let g:clever_f_mark_char = saved_mark_char
|
||||
End
|
||||
|
||||
It should highlight the target characters automatically
|
||||
normal! gg0
|
||||
normal fh
|
||||
Assert NotEquals(filter(getmatches(), 'v:val.group==#"CleverFChar"'), [])
|
||||
Assert NotEquals(Highlights(), [])
|
||||
normal f
|
||||
Assert NotEquals(filter(getmatches(), 'v:val.group==#"CleverFChar"'), [])
|
||||
Assert NotEquals(Highlights(), [])
|
||||
End
|
||||
|
||||
It should update the highlight if the cursor moves to another line
|
||||
It should update the highlight when the cursor moves to another line
|
||||
call AddLine('oh huh')
|
||||
normal! gg0
|
||||
let l = line('.')
|
||||
normal fhff
|
||||
Assert NotEquals(filter(getmatches(), 'v:val.group==#"CleverFChar"'), [])
|
||||
Assert NotEquals(Highlights(), [])
|
||||
Assert NotEquals(stridx(getmatches()[0].pattern, l), -1)
|
||||
Assert Equals(len(getmatches()), 1)
|
||||
normal f
|
||||
Assert NotEquals(filter(getmatches(), 'v:val.group==#"CleverFChar"'), [])
|
||||
Assert NotEquals(Highlights(), [])
|
||||
Assert NotEquals(stridx(getmatches()[0].pattern, l+1), -1)
|
||||
Assert Equals(len(getmatches()), 1)
|
||||
normal f
|
||||
Assert NotEquals(filter(getmatches(), 'v:val.group==#"CleverFChar"'), [])
|
||||
Assert NotEquals(Highlights(), [])
|
||||
Assert NotEquals(stridx(getmatches()[0].pattern, l+1), -1)
|
||||
Assert Equals(len(getmatches()), 1)
|
||||
End
|
||||
@ -978,7 +1060,7 @@ Describe g:clever_f_mark_char
|
||||
" XXX: Hack! While running test, CursorMoved is not fired
|
||||
" automatically. To test the event, we need to cause it manually.
|
||||
doautocmd CursorMoved
|
||||
Assert Equals(filter(getmatches(), 'v:val.group==#"CleverFChar"'), [])
|
||||
Assert Equals(Highlights(), [])
|
||||
End
|
||||
|
||||
It should remove highlights when entering insert mode
|
||||
@ -989,19 +1071,16 @@ Describe g:clever_f_mark_char
|
||||
" XXX: Hack! While running test, InsertEnter is not fired
|
||||
" automatically. To test the event, we need to cause it manually.
|
||||
doautocmd InsertEnter
|
||||
Assert Equals(filter(getmatches(), 'v:val.group==#"CleverFChar"'), [])
|
||||
Assert Equals(Highlights(), [])
|
||||
End
|
||||
|
||||
Describe clever_f#reset()
|
||||
It should remove target highlights
|
||||
call AddLine('oh huh')
|
||||
normal! gg0
|
||||
let l = line('.')
|
||||
normal fhff
|
||||
Assert NotEquals(filter(getmatches(), 'v:val.group==#"CleverFChar"'), [])
|
||||
call clever_f#reset()
|
||||
Assert Equals(filter(getmatches(), 'v:val.group==#"CleverFChar"'), [])
|
||||
End
|
||||
It should not highlight target character when set to 0
|
||||
let g:clever_f_mark_char = 0
|
||||
normal! gg0
|
||||
normal fh
|
||||
Assert Equals(Highlights(), [])
|
||||
normal f
|
||||
Assert Equals(Highlights(), [])
|
||||
End
|
||||
End
|
||||
|
||||
@ -1294,4 +1373,128 @@ Describe g:clever_f_mark_direct
|
||||
Assert Equals(len(filter(getmatches(), 'v:val.group ==# "CleverFDirect"')), 0)
|
||||
End
|
||||
End
|
||||
" vim:foldmethod=marker
|
||||
|
||||
Describe g:clever_f_highlight_timeout_ms
|
||||
Before
|
||||
new
|
||||
let g:clever_f_mark_char = 1
|
||||
let g:clever_f_highlight_timeout_ms = 100
|
||||
call clever_f#reset()
|
||||
call AddLine('pOge huga Hiyo poyooooooooooooooooooooooooooooooooooooooooooooooooooo')
|
||||
normal! gg0
|
||||
End
|
||||
|
||||
After
|
||||
close!
|
||||
let g:clever_f_highlight_timeout_ms = 0
|
||||
End
|
||||
|
||||
It should remove highlights after specified timeout
|
||||
let start = reltime()
|
||||
normal fo
|
||||
Assert NotEquals(Highlights(), [])
|
||||
sleep 10m
|
||||
Assert NotEquals(Highlights(), [])
|
||||
Assert WaitUntil(100, { -> Highlights() == [] })
|
||||
let duration = reltimefloat(reltime(start))
|
||||
Assert Truthy(duration > 0.1, string(duration) . ' should be greater than 0.1')
|
||||
End
|
||||
|
||||
It should not remove highlights while repeating search
|
||||
let start = reltime()
|
||||
normal fo
|
||||
" After 500ms highlights are not removed since 'f' resets timer
|
||||
for _ in range(10)
|
||||
sleep 50m
|
||||
Assert NotEquals(Highlights(), [])
|
||||
normal f
|
||||
endfor
|
||||
" Spending 100ms without 'f' expires the timer
|
||||
Assert WaitUntil(120, { -> Highlights() == [] })
|
||||
End
|
||||
|
||||
It should restore highlights after timeout removed it
|
||||
normal fo
|
||||
Assert NotEquals(Highlights(), [])
|
||||
|
||||
" Wait until highlights are removed due to timeout
|
||||
Assert WaitUntil(200, { -> Highlights() == [] })
|
||||
|
||||
" repeat f
|
||||
normal f
|
||||
|
||||
" Highlights are restored
|
||||
Assert NotEquals(Highlights(), [])
|
||||
|
||||
" Finally highlights are removed again
|
||||
Assert WaitUntil(200, { -> Highlights() == [] })
|
||||
End
|
||||
End
|
||||
|
||||
Describe .
|
||||
Before each
|
||||
new
|
||||
call AddLine('hoge fuge piye poye')
|
||||
normal! gg0
|
||||
End
|
||||
|
||||
After each
|
||||
close!
|
||||
End
|
||||
|
||||
It should repeat 'f' mapping
|
||||
normal dfe
|
||||
Assert Equals(getline('.'), ' fuge piye poye')
|
||||
|
||||
normal! .
|
||||
Assert Equals(getline('.'), ' piye poye')
|
||||
|
||||
normal! .
|
||||
Assert Equals(getline('.'), ' poye')
|
||||
|
||||
normal! .
|
||||
Assert Equals(getline('.'), '')
|
||||
End
|
||||
|
||||
It should repeat 't' mapping
|
||||
normal dte
|
||||
Assert Equals(getline('.'), 'e fuge piye poye')
|
||||
|
||||
normal! .
|
||||
Assert Equals(getline('.'), 'e piye poye')
|
||||
|
||||
normal! .
|
||||
Assert Equals(getline('.'), 'e poye')
|
||||
|
||||
normal! .
|
||||
Assert Equals(getline('.'), 'e')
|
||||
End
|
||||
|
||||
It should repeat 'F' mapping
|
||||
normal! $
|
||||
|
||||
normal dFe
|
||||
Assert Equals(getline('.'), 'hoge fuge piye')
|
||||
|
||||
normal .
|
||||
Assert Equals(getline('.'), 'hoge fuge')
|
||||
|
||||
normal .
|
||||
Assert Equals(getline('.'), 'hoge')
|
||||
End
|
||||
|
||||
It should repeat 'T' mapping
|
||||
normal! $
|
||||
|
||||
normal dTe
|
||||
Assert Equals(getline('.'), 'hoge fuge piyee')
|
||||
|
||||
normal .
|
||||
Assert Equals(getline('.'), 'hoge fugee')
|
||||
|
||||
normal .
|
||||
Assert Equals(getline('.'), 'hogee')
|
||||
End
|
||||
End
|
||||
|
||||
" vim: set ft=vim foldmethod=marker:
|
||||
|
Loading…
Reference in New Issue
Block a user