[vim/vim] Trigger TextChanged after TextChangedI correctly (#8968)

15 views
Skip to first unread message

Christian Brabandt

unread,
Oct 6, 2021, 5:37:38 AM10/6/21
to vim/vim, Subscribed

Use a separate variable for deciding whether or not to trigger
TextChangedI autocommand or not. Else we may skip an existing
TextChanged autocommand, just because TextChangedI triggered right
before.

fixes #8932

Note the test: For some reason, evaluating the g:autocmd_n variable was
never performed, therefore currently disabled. I tried different variations
of feedkeys() with different flags and :norm! commands. I could never make it trigger
when run automatically...

Not sure why, it works when running the test interactively, so probably something with
type-ahead?

I also verified, it fixes the issue mentioned in #8932.

If anybody has an idea to trigger TextChanged correctly in the test, please let me know.


You can view, comment on, or merge this pull request online at:

  https://github.com/vim/vim/pull/8968

Commit Summary

File Changes

Patch Links:


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub.
Triage notifications on the go with GitHub Mobile for iOS or Android.

codecov[bot]

unread,
Oct 6, 2021, 5:40:06 AM10/6/21
to vim/vim, Subscribed

Codecov Report

Merging #8968 (5bbbe68) into master (78e0fa4) will decrease coverage by 87.63%.
The diff coverage is 0.00%.

Current head 5bbbe68 differs from pull request most recent head 33a14da. Consider uploading reports for the commit 33a14da to get more accurate results
Impacted file tree graph

@@             Coverage Diff             @@

##           master    #8968       +/-   ##

===========================================

- Coverage   90.08%    2.45%   -87.64%     

===========================================

  Files         151      149        -2     

  Lines      168914   165926     -2988     

===========================================

- Hits       152171     4077   -148094     

- Misses      16743   161849   +145106     
Flag Coverage Δ
huge-clang-none ?
huge-gcc-none ?
huge-gcc-testgui ?
huge-gcc-unittests 2.45% <0.00%> (-0.01%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
src/buffer.c 3.46% <0.00%> (-88.69%) ⬇️
src/bufwrite.c 0.00% <ø> (-84.41%) ⬇️
src/edit.c 0.00% <0.00%> (-92.91%) ⬇️
src/float.c 0.00% <0.00%> (-99.22%) ⬇️
src/gui_gtk_f.c 0.00% <0.00%> (-97.43%) ⬇️
src/crypt_zip.c 0.00% <0.00%> (-97.06%) ⬇️
src/cmdhist.c 0.00% <0.00%> (-97.00%) ⬇️
src/sha256.c 0.00% <0.00%> (-96.94%) ⬇️
src/evalbuffer.c 0.00% <0.00%> (-96.88%) ⬇️
src/textprop.c 0.00% <0.00%> (-96.84%) ⬇️
... and 140 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 78e0fa4...33a14da. Read the comment docs.

Bram Moolenaar

unread,
Oct 16, 2021, 6:45:37 AM10/16/21
to vim/vim, Subscribed


> Use a separate variable for deciding whether or not to trigger
> TextChangedI autocommand or not. Else we may skip an existing
> TextChanged autocommand, just because TextChangedI triggered right
> before.
>
> fixes #8932
>
> Note the test: For some reason, evaluating the g:autocmd_n variable was
> never performed, therefore currently disabled. I tried different variations
> of `feedkeys()` with different flags and `:norm!` commands. I could
> never make it trigger when run automatically...
>
> Not sure why, it works when running the test interactively, so
> probably something with type-ahead?

It needs to go through the main loop, which is where TextChange is
triggered. But when sourcing a script it doesn't get there. There is
one trick using a :global command:
:g/pat/visual<NL>cmd

Where "cmd" is a Normal mode command. It then main_loop() to execute
it. Let's see if I can make this work.


--
hundred-and-one symptoms of being an internet addict:
166. You have been on your computer soo long that you didn't realize
you had grandchildren.

/// Bram Moolenaar -- ***@***.*** -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Bram Moolenaar

unread,
Oct 16, 2021, 6:54:39 AM10/16/21
to vim...@googlegroups.com, Bram Moolenaar

> > Use a separate variable for deciding whether or not to trigger
> > TextChangedI autocommand or not. Else we may skip an existing
> > TextChanged autocommand, just because TextChangedI triggered right
> > before.
> >
> > fixes #8932
> >
> > Note the test: For some reason, evaluating the g:autocmd_n variable was
> > never performed, therefore currently disabled. I tried different variations
> > of `feedkeys()` with different flags and `:norm!` commands. I could
> > never make it trigger when run automatically...
> >
> > Not sure why, it works when running the test interactively, so
> > probably something with type-ahead?
>
> It needs to go through the main loop, which is where TextChange is
> triggered. But when sourcing a script it doesn't get there. There is
> one trick using a :global command:
> :g/pat/visual<NL>cmd
>
> Where "cmd" is a Normal mode command. It then main_loop() to execute
> it. Let's see if I can make this work.

Well, it works when run separately, but I can't make it work in a test.
That makes it hard to debug.

I think the only way is to run Vim in a terminal window and send it keys
from the test. Like what is done in Test_Changed_FirstTime()
Can you look into that Christian?

--
hundred-and-one symptoms of being an internet addict:
168. You have your own domain name.

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\

Bram Moolenaar

unread,
Oct 16, 2021, 6:59:44 AM10/16/21
to vim/vim, Subscribed

Closed #8968 via db3b446.

Reply all
Reply to author
Forward
0 new messages