Hi Dominique,

On Wed, Feb 5, 2020 at 12:23 PM Bram Moolenaar <[email protected]> wrote:
>
>
> Dominique wrote:
>
> > Bram Moolenaar <[email protected]> wrote:
> >
> > > Patch 8.2.0212
> > > Problem:    Missing search/substitute pattern hardly tested.
> > > Solution:   Add test_clear_search_pat() and tests. (Yegappan Lakshmanan,
> > >             closes #5579)
> > > Files:      runtime/doc/eval.txt, runtime/doc/testing.txt,
> > >             runtime/doc/usr_41.txt, src/evalfunc.c, src/proto/regexp.pro,
> > >             src/proto/search.pro, src/proto/testing.pro, src/regexp.c,
> > >             src/search.c, src/testdir/test_quickfix.vim,
> > >             src/testdir/test_search.vim, src/testdir/test_sort.vim,
> > >             src/testdir/test_substitute.vim, src/testing.c
> > >
> > >
> > > *** ../vim-8.2.0211/runtime/doc/eval.txt        2020-01-26 
> > > 15:52:33.011833294 +0100
> > > --- runtime/doc/eval.txt        2020-02-05 20:14:30.082087884 +0100
> > > ***************
> > > *** 2846,2851 ****
> > > --- 2848,2854 ----
> > >   test_alloc_fail({id}, {countdown}, {repeat})
> > >                                 none    make memory allocation fail
> > >   test_autochdir()              none    enable 'autochdir' during startup
> > > + test_clear_search_pat()               none    clears the last used 
> > > search pattern
> > >   test_feedinput({string})      none    add key sequence to input buffer
> > >   test_garbagecollect_now()     none    free memory right now for testing
> > >   test_garbagecollect_soon()    none    free memory soon for testing
> >
> >
> > Couldn't we test the missing last search pattern by using the
> > existing  :call histdel('/', '.*')  in tests, instead of by introducing
> > a new function test_clear_search_pat()?
>
> histdel() only clears the command line history, not the search pattern.
>
> This comes closer, but also doesn't work:
>         :let @/ = test_null_string()
>

Yes. As Bram described above, the histdel() function only removes the
entry from the search history. It doesn't reset the internal state of the
"/" register to the default state.

Vim internally maintains two last search patterns. One is from the search
commands (/ and ?) and the other is from the substitute command.
There is also another copy maintained by the regex code to support
the ~ (tilde) atom. The new test_clear_search_pat() function resets
all the internal state for the search patterns to the default state.

Regards,
Yegappan

-- 
-- 
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php

--- 
You received this message because you are subscribed to the Google Groups 
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vim_dev/CAAW7x7mfm3j4c-i-N6AZuLoixxgy2cuNN-qARo8iJaS6LDx3kw%40mail.gmail.com.

Raspunde prin e-mail lui