Mercurial > vim
comparison src/ops.c @ 15048:73f59cd01ba7 v8.1.0535
patch 8.1.0535: increment/decrement might get interrupted by updating folds
commit https://github.com/vim/vim/commit/6b731886ca94d66b9bdedfb7e603af44a6400399
Author: Bram Moolenaar <Bram@vim.org>
Date: Fri Nov 16 20:54:47 2018 +0100
patch 8.1.0535: increment/decrement might get interrupted by updating folds
Problem: Increment/decrement might get interrupted by updating folds.
Solution: Disable fold updating for a moment. (Christian Brabandt,
closes #3599)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Fri, 16 Nov 2018 21:00:06 +0100 |
parents | 27b9a84395b5 |
children | 3a94f7918980 |
comparison
equal
deleted
inserted
replaced
15047:63e1c9a38553 | 15048:73f59cd01ba7 |
---|---|
5547 pos_T pos; | 5547 pos_T pos; |
5548 struct block_def bd; | 5548 struct block_def bd; |
5549 int change_cnt = 0; | 5549 int change_cnt = 0; |
5550 linenr_T amount = Prenum1; | 5550 linenr_T amount = Prenum1; |
5551 | 5551 |
5552 // do_addsub() might trigger re-evaluation of 'foldexpr' halfway, when the | |
5553 // buffer is not completly updated yet. Postpone updating folds until before | |
5554 // the call to changed_lines(). | |
5555 #ifdef FEAT_FOLDING | |
5556 disable_fold_update++; | |
5557 #endif | |
5558 | |
5552 if (!VIsual_active) | 5559 if (!VIsual_active) |
5553 { | 5560 { |
5554 pos = curwin->w_cursor; | 5561 pos = curwin->w_cursor; |
5555 if (u_save_cursor() == FAIL) | 5562 if (u_save_cursor() == FAIL) |
5563 { | |
5564 #ifdef FEAT_FOLDING | |
5565 disable_fold_update--; | |
5566 #endif | |
5556 return; | 5567 return; |
5568 } | |
5557 change_cnt = do_addsub(oap->op_type, &pos, 0, amount); | 5569 change_cnt = do_addsub(oap->op_type, &pos, 0, amount); |
5570 #ifdef FEAT_FOLDING | |
5571 disable_fold_update--; | |
5572 #endif | |
5558 if (change_cnt) | 5573 if (change_cnt) |
5559 changed_lines(pos.lnum, 0, pos.lnum + 1, 0L); | 5574 changed_lines(pos.lnum, 0, pos.lnum + 1, 0L); |
5560 } | 5575 } |
5561 else | 5576 else |
5562 { | 5577 { |
5564 int length; | 5579 int length; |
5565 pos_T startpos; | 5580 pos_T startpos; |
5566 | 5581 |
5567 if (u_save((linenr_T)(oap->start.lnum - 1), | 5582 if (u_save((linenr_T)(oap->start.lnum - 1), |
5568 (linenr_T)(oap->end.lnum + 1)) == FAIL) | 5583 (linenr_T)(oap->end.lnum + 1)) == FAIL) |
5584 { | |
5585 #ifdef FEAT_FOLDING | |
5586 disable_fold_update--; | |
5587 #endif | |
5569 return; | 5588 return; |
5589 } | |
5570 | 5590 |
5571 pos = oap->start; | 5591 pos = oap->start; |
5572 for (; pos.lnum <= oap->end.lnum; ++pos.lnum) | 5592 for (; pos.lnum <= oap->end.lnum; ++pos.lnum) |
5573 { | 5593 { |
5574 if (oap->block_mode) /* Visual block mode */ | 5594 if (oap->block_mode) /* Visual block mode */ |
5622 } | 5642 } |
5623 #endif | 5643 #endif |
5624 if (g_cmd && one_change) | 5644 if (g_cmd && one_change) |
5625 amount += Prenum1; | 5645 amount += Prenum1; |
5626 } | 5646 } |
5647 | |
5648 #ifdef FEAT_FOLDING | |
5649 disable_fold_update--; | |
5650 #endif | |
5627 if (change_cnt) | 5651 if (change_cnt) |
5628 changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L); | 5652 changed_lines(oap->start.lnum, 0, oap->end.lnum + 1, 0L); |
5629 | 5653 |
5630 if (!change_cnt && oap->is_VIsual) | 5654 if (!change_cnt && oap->is_VIsual) |
5631 /* No change: need to remove the Visual selection */ | 5655 /* No change: need to remove the Visual selection */ |