Skip to content

Conversation

Shougo
Copy link
Contributor

@Shougo Shougo commented Sep 16, 2016

I have fixed fold update problem.
The fold is updated in insertleave or nv_replace if the update is skipped.
It fixes #5299 test failures.

Note: nv_replace is normal-mode r implementation.
It enters insert mode and change text.
So, the fix is needed...

@Shougo
Copy link
Contributor Author

Shougo commented Sep 17, 2016

Fixed tests.

@Shougo
Copy link
Contributor Author

Shougo commented Sep 17, 2016

All tests are passed!

@justinmk
Copy link
Member

Why not always update folds after leaving insert-mode? That avoids the global flag.

@Shougo
Copy link
Contributor Author

Shougo commented Sep 17, 2016

OK.

@Shougo
Copy link
Contributor Author

Shougo commented Sep 18, 2016

This fix is OK?


fold_T *fp;
if (wp->w_buffer->terminal) {
if (compl_busy || State & INSERT || wp->w_buffer->terminal) {
Copy link
Member

Choose a reason for hiding this comment

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

why not in terminal buffers?

@@ -462,6 +462,8 @@ static void insert_enter(InsertState *s)
o_lnum = curwin->w_cursor.lnum;
}

foldUpdateAll(curwin);
foldOpenCursor();
Copy link
Member

@justinmk justinmk Sep 18, 2016

Choose a reason for hiding this comment

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

What was calling foldUpdateAll() before now? We are adding new calls, but can we delete the old one? changed_common was the origin, nothing we can remove there.

Copy link
Member

@justinmk justinmk Sep 18, 2016

Choose a reason for hiding this comment

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

@Shougo This seems to open folds on any cursor motion (not change) now. Why is foldOpenCursor() needed? Can we remove it?

@@ -5924,6 +5924,9 @@ static void nv_replace(cmdarg_T *cap)
curwin->w_set_curswant = true;
set_last_insert(cap->nchar);
}

foldUpdateAll(curwin);
foldOpenCursor();
Copy link
Member

@justinmk justinmk Sep 18, 2016

Choose a reason for hiding this comment

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

Why is this needed? insert_enter() should be enough. The comment above edit() mentions that it handles gr, gR, R, etc.

Copy link
Member

@justinmk justinmk Sep 18, 2016

Choose a reason for hiding this comment

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

I see now only a special case of r is handled by edit(). But why didn't change_common take care of it?

Looking...

It seems the foldUpdate call in change_common doesn't invalidate window folds. So that's why foldUpdateAll is needed.

justinmk pushed a commit that referenced this pull request Sep 18, 2016
Fixes failing test: 045_folding_spec.lua
References #5299
@justinmk
Copy link
Member

Merged. Thanks @Shougo !

@justinmk justinmk closed this Sep 18, 2016
@Shougo Shougo deleted the fold branch September 19, 2016 06:56
@Shougo
Copy link
Contributor Author

Shougo commented Sep 19, 2016

Thank you!

@Shougo
Copy link
Contributor Author

Shougo commented Sep 19, 2016

I have updated the vim_dev patch.

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.

2 participants