Skip to content

Conversation

Shougo
Copy link
Contributor

@Shougo Shougo commented Oct 4, 2016

It fixes the slowness in InsertLeave if you use syntax/expr folding.

@justinmk
Copy link
Member

Did you have any updates to this? Or is it ready?

if (foldmethodIsManual(curwin)
|| foldmethodIsSyntax(curwin)
|| foldmethodIsExpr(curwin)) {
return;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why are only these skipped, but not other fold methods?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think them should be updated.
manual: No need to update
syntax and expr: Auto update is slow. It should be updated manually like FastFold plugin

@Shougo
Copy link
Contributor Author

Shougo commented Oct 18, 2016

Did you have any updates to this? Or is it ready?

It is ready.

@Shougo Shougo changed the title Disable syntax folding update in InsertLeave [RFC] Disable syntax folding update in InsertLeave Oct 18, 2016
@marvim marvim added the RFC label Oct 18, 2016
@justinmk
Copy link
Member

Merged

@justinmk justinmk closed this Oct 19, 2016
@justinmk justinmk removed the RFC label Oct 19, 2016
@Shougo Shougo deleted the fold branch October 19, 2016 22:41
@Shougo
Copy link
Contributor Author

Shougo commented Oct 19, 2016

Thank you!

@choco
Copy link
Contributor

choco commented Oct 20, 2016

I understand the reasoning behind this change, but how can I update the folds manually now? zx and zX don't really do what I want.
It would be cool if this change also included a :foldupdate command so I can call it when I want the folds updated.

@justinmk
Copy link
Member

@Shougo What do you think?

@Shougo
Copy link
Contributor Author

Shougo commented Oct 20, 2016

@choco Please change foldmethod value. It resets the folds.

@justinmk
Copy link
Member

@choco Which foldmethod are you using? And why doesn't zx work for you?

@Shougo
Copy link
Contributor Author

Shougo commented Oct 20, 2016

Oh, I get it.
I don't use zx ever...

@choco
Copy link
Contributor

choco commented Oct 20, 2016

@Shougo that works, but it isn't really "user friendly" :/ I still think a command would be worth it.

@justinmk I'm using syntax. zx also reapplys fold level, so some folds that weren't closed get closed, etc....

Anyway this behaviour change should probably be noted in the documentation.

@Shougo
Copy link
Contributor Author

Shougo commented Oct 20, 2016

Hm. Vim already have foldopen, foldclose, ... commands.
Why no :foldupdate command in Vim.

@Shougo
Copy link
Contributor Author

Shougo commented Oct 20, 2016

@choco Can you ask the question in the issue?

vim/vim#1045

@justinmk
Copy link
Member

Wait. Why would we add :foldupdate after we just disabled auto-update-of-folds? If this PR broke something we should let auto-updating happen after insert-leave.

@choco
Copy link
Contributor

choco commented Oct 20, 2016

After #5299 and #5351 folds weren't updated in insert mode while typing, but only when leaving it. This PR disabled folds update at insert leave for the slower modes (and manual since it doesn't need updating anyway).

So this PR broke previous behaviour, new text inserted doesn't update folds. Just commented since I think:

  1. change should be mentioned in the documentation, users expect folds to autoupdate.
  2. add a foldupdate command (complementary to foldopen etc.. since zx also reapplys fold level) to have a friendly way to update folds.

@justinmk
Copy link
Member

justinmk commented Oct 20, 2016

This PR disabled folds update at insert leave for the slower modes (and manual since it doesn't need updating anyway).

If user has to manually call (or map) :foldupdate it seems like we didn't improve anything. We went from "slow insert-leave" to "user needs to pay attention and manage their folds".

So I think we should auto-update folds after insert-leave, for everything except foldmethod=manual.

@Shougo
Copy link
Contributor Author

Shougo commented Oct 20, 2016

So I think we should auto-update folds after insert-leave, for everything except foldmethod=manual.

I don't like the auto update.
It is slow even if you edit 4000 lines help file.

@choco
Copy link
Contributor

choco commented Oct 20, 2016

So I think we should auto-update folds after insert-leave, for everything except foldmethod=manual.

Well, updating at insert leave feels really bad when editing even moderately big files :( I personally would call foldupdate on BufWrite or manually.

The best solution would be to optimize syntax fold method but last time I took a look most of the time is spent in the regex engine, so I don't think there's a lot that can be done there without moving away from it.

@Shougo
Copy link
Contributor Author

Shougo commented Oct 20, 2016

Here.
vim/vim#1045 (comment)

@justinmk
Copy link
Member

Ok, how about doing it on CursorHold and BufWrite ?

@Shougo
Copy link
Contributor Author

Shougo commented Oct 20, 2016

CursorHold is also slow.
But BufWritePost timing is not so bad.

@choco
Copy link
Contributor

choco commented Oct 24, 2016

Yeah BufWritePost seems reasonable 👍

justinmk added a commit to justinmk/neovim that referenced this pull request Oct 27, 2016
FEATURES:
0b5a7e4 neovim#4432 API: external UIs can render custom popupmenu
c6ac4f8 neovim#4934 API: call any API method from vimscript
31df051 neovim#4568 API: nvim_call_atomic(): multiple calls in a single request
b268ba3 neovim#5424 API: nvim_win_get_number(), nvim_tabpage_get_number()
e7e2844 has("nvim-1.2.3") checks for a specific Nvim version
522b885 neovim#5295, neovim#5493 `:CheckHealth` checks tmux, terminfo, performance
719dae2 neovim#5384 events: allow event processing in getchar()
f25797f neovim#5386 API: metadata: Nvim version & API level
22dfe69 neovim#5389 API: metadata: "since", "deprecated_since"
605e743 Added QuickFixLine highlight group

CHANGES:
4af6ec7 neovim#5253 perf: Disable clipboard in do_cmdline()
6e9f329 neovim#5299 perf: Skip foldUpdate() in insert-mode.
9d4fcec neovim#5426 perf: Do not auto-update folds for some foldmethods.
eeec0ca neovim#5419 tui: Default to normal-mode cursor shape.

FIXES:
e838452 neovim#5436 tui: Fix "weird characters" / "bleeding termcodes"
10a54ad neovim#5243 signal_init: Always unblock SIGCHLD.
bccb49b neovim#5316 eval.c: Fix memory leak for detached pty job
626065d neovim#5227 tchdir: New tab should inherit CWD.
cd321b7 neovim#5292 getcwd(): Return empty string if CWD is invalid.
6127eae shada: Fix non-writeable ShaDa directory handling
ca65514 neovim#2789 system(): Respect shellxescape, shellxquote
2daf54e neovim#4874 Restore vim-like tab dragging
0c536b5 neovim#5319 syntax.c: Support bg/fg special color-names.
3c53371 neovim#4972 from justinmk/schedule-ui_refresh
68bcb32 neovim#4789 tui.c: Do not wait for tui loop on teardown.
c8b6ec2 neovim#5409 v:count broken in command-line window
6bc3bce neovim#5461 fix emoji display
51937e1 neovim#5470 fix :terminal with :argadd, :argu
79d77da neovim#5481 external UIs: opening multiple files from command-line
657ba62 neovim#5501 rplugin: resolve paths in manifest file
6a6f188 neovim#5502 system('foo &', 'bar'): Show error, don't crash.
1ff162c neovim#5515 os_nodetype: open fd with O_NONBLOCK
2a6c5bb neovim#5450 modeline: Handle version number overflow.
0ade1bb neovim#5225 CI tests now run against Windows!
justinmk added a commit to justinmk/neovim that referenced this pull request Oct 28, 2016
FEATURES:
0b5a7e4 neovim#4432 API: external UIs can render custom popupmenu
c6ac4f8 neovim#4934 API: call any API method from vimscript
31df051 neovim#4568 API: nvim_call_atomic(): multiple calls in a single request
b268ba3 neovim#5424 API: nvim_win_get_number(), nvim_tabpage_get_number()
e7e2844 has("nvim-1.2.3") checks for a specific Nvim version
522b885 neovim#5295, neovim#5493 `:CheckHealth` checks tmux, terminfo, performance
719dae2 neovim#5384 events: allow event processing in getchar()
f25797f neovim#5386 API: metadata: Nvim version & API level
22dfe69 neovim#5389 API: metadata: "since", "deprecated_since"
605e743 Added QuickFixLine highlight group

CHANGES:
4af6ec7 neovim#5253 perf: Disable clipboard in do_cmdline()
6e9f329 neovim#5299 perf: Skip foldUpdate() in insert-mode.
9d4fcec neovim#5426 perf: Do not auto-update folds for some foldmethods.
eeec0ca neovim#5419 tui: Default to normal-mode cursor shape.

FIXES:
e838452 neovim#5436 tui: Fix "weird characters" / "bleeding termcodes"
10a54ad neovim#5243 signal_init: Always unblock SIGCHLD.
bccb49b neovim#5316 eval.c: Fix memory leak for detached pty job
626065d neovim#5227 tchdir: New tab should inherit CWD.
cd321b7 neovim#5292 getcwd(): Return empty string if CWD is invalid.
6127eae shada: Fix non-writeable ShaDa directory handling
ca65514 neovim#2789 system(): Respect shellxescape, shellxquote
2daf54e neovim#4874 Restore vim-like tab dragging
0c536b5 neovim#5319 syntax.c: Support bg/fg special color-names.
3c53371 neovim#4972 from justinmk/schedule-ui_refresh
68bcb32 neovim#4789 tui.c: Do not wait for tui loop on teardown.
c8b6ec2 neovim#5409 v:count broken in command-line window
6bc3bce neovim#5461 fix emoji display
51937e1 neovim#5470 fix :terminal with :argadd, :argu
79d77da neovim#5481 external UIs: opening multiple files from command-line
657ba62 neovim#5501 rplugin: resolve paths in manifest file
6a6f188 neovim#5502 system('foo &', 'bar'): Show error, don't crash.
1ff162c neovim#5515 os_nodetype: open fd with O_NONBLOCK
2a6c5bb neovim#5450 modeline: Handle version number overflow.
0ade1bb neovim#5225 CI tests now run against Windows!
@Shougo
Copy link
Contributor Author

Shougo commented Oct 31, 2016

I have fixed the problem in insert mode.
But foldmethod is also slow in normal mode. Oh, no...
Shougo/neosnippet.vim#356

@justinmk
Copy link
Member

justinmk commented Nov 8, 2016

zx also reapplys fold level, so some folds that weren't closed get closed, etc....

@choco Does zizi help? What about doing another set foldenable?

@choco
Copy link
Contributor

choco commented Nov 16, 2016

@justinmk nope, Shougo method above is the only one working

@justinmk
Copy link
Member

anyone want to send a patch for :foldupdate ?

@choco
Copy link
Contributor

choco commented Nov 16, 2016

If there's no rush I can probably send something (since I'm also the one bugging about it :>), but not before next weekend.

@justinmk
Copy link
Member

justinmk commented Mar 3, 2017

@choco Instead of :foldupdate, it might be enough to CTRL-L. Could you try that?

justinmk added a commit to justinmk/neovim that referenced this pull request Mar 3, 2017
@choco
Copy link
Contributor

choco commented Mar 4, 2017

@justinmk Yep, it seems to work indeed. Sorry for not getting back before, been pretty busy last couple of months.

justinmk added a commit to justinmk/neovim that referenced this pull request Mar 4, 2017
@choco
Copy link
Contributor

choco commented Mar 5, 2017

@justinmk just wanted to point out that I tried to apply the fix in the pull request above and it doesn't work. I still need to press ctrl-L for the folds to update.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants