Mercurial > vim
comparison src/fold.c @ 28578:8cba27db759a v8.2.4813
patch 8.2.4813: pasting text while indent folding may mess up folds
Commit: https://github.com/vim/vim/commit/2c40707baa13a53cac4137ffb8b2ac67f50cea63
Author: Brandon Simmons <simmsbra@gmail.com>
Date: Sat Apr 23 13:50:17 2022 +0100
patch 8.2.4813: pasting text while indent folding may mess up folds
Problem: Pasting text while indent folding may mess up folds.
Solution: Adjust the way folds are split. (Brandon Simmons, closes https://github.com/vim/vim/issues/10254)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Sat, 23 Apr 2022 15:00:03 +0200 |
parents | c1d1639b52dd |
children | d770568e6c98 |
comparison
equal
deleted
inserted
replaced
28577:46633e743329 | 28578:8cba27db759a |
---|---|
1126 } | 1126 } |
1127 | 1127 |
1128 // foldFind() {{{2 | 1128 // foldFind() {{{2 |
1129 /* | 1129 /* |
1130 * Search for line "lnum" in folds of growarray "gap". | 1130 * Search for line "lnum" in folds of growarray "gap". |
1131 * Set *fpp to the fold struct for the fold that contains "lnum" or | 1131 * Set "*fpp" to the fold struct for the fold that contains "lnum" or |
1132 * the first fold below it (careful: it can be beyond the end of the array!). | 1132 * the first fold below it (careful: it can be beyond the end of the array!). |
1133 * Returns FALSE when there is no fold that contains "lnum". | 1133 * Returns FALSE when there is no fold that contains "lnum". |
1134 */ | 1134 */ |
1135 static int | 1135 static int |
1136 foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp) | 1136 foldFind(garray_T *gap, linenr_T lnum, fold_T **fpp) |
2909 | 2909 |
2910 // Move nested folds below bot to new fold. There can't be | 2910 // Move nested folds below bot to new fold. There can't be |
2911 // any between top and bot, they have been removed by the caller. | 2911 // any between top and bot, they have been removed by the caller. |
2912 gap1 = &fp->fd_nested; | 2912 gap1 = &fp->fd_nested; |
2913 gap2 = &fp[1].fd_nested; | 2913 gap2 = &fp[1].fd_nested; |
2914 if (foldFind(gap1, bot + 1 - fp->fd_top, &fp2)) | 2914 (void)foldFind(gap1, bot + 1 - fp->fd_top, &fp2); |
2915 if (fp2 != NULL) | |
2915 { | 2916 { |
2916 len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2); | 2917 len = (int)((fold_T *)gap1->ga_data + gap1->ga_len - fp2); |
2917 if (len > 0 && ga_grow(gap2, len) == OK) | 2918 if (len > 0 && ga_grow(gap2, len) == OK) |
2918 { | 2919 { |
2919 for (idx = 0; idx < len; ++idx) | 2920 for (idx = 0; idx < len; ++idx) |