Mercurial > vim
comparison src/textprop.c @ 19631:1d493fce1fbd v8.2.0372
patch 8.2.0372: prop_find() may not find text property at start of the line
Commit: https://github.com/vim/vim/commit/66b98854d86f641db036fd1e6cf20f7b8905344e
Author: Bram Moolenaar <Bram@vim.org>
Date: Wed Mar 11 19:15:52 2020 +0100
patch 8.2.0372: prop_find() may not find text property at start of the line
Problem: Prop_find() may not find text property at start of the line.
Solution: Adjust the loop to find properties. (Axel Forsman, closes https://github.com/vim/vim/issues/5761,
closes #5663)
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Wed, 11 Mar 2020 21:31:02 +0100 |
parents | 67f39cb0a49c |
children | 647ef636a11e |
comparison
equal
deleted
inserted
replaced
19630:522158d28042 | 19631:1d493fce1fbd |
---|---|
661 for (i = 0; i < count; ++i) | 661 for (i = 0; i < count; ++i) |
662 { | 662 { |
663 mch_memmove(&prop, text + textlen + i * sizeof(textprop_T), | 663 mch_memmove(&prop, text + textlen + i * sizeof(textprop_T), |
664 sizeof(textprop_T)); | 664 sizeof(textprop_T)); |
665 | 665 |
666 if (dir < 0) | |
667 { | |
668 if (col < prop.tp_col) | |
669 break; | |
670 } | |
671 else if (prop.tp_col + prop.tp_len - (prop.tp_len != 0) < col) | |
672 continue; | |
673 | |
666 if (prop.tp_id == id || prop.tp_type == type_id) | 674 if (prop.tp_id == id || prop.tp_type == type_id) |
667 { | 675 { |
668 // Check if the starting position has text props. | 676 // Check if the starting position has text props. |
669 if (lnum_start == lnum) | 677 if (lnum_start == lnum |
670 { | 678 && col >= prop.tp_col |
671 if (col >= prop.tp_col | 679 && (col <= prop.tp_col + prop.tp_len |
672 && (col <= prop.tp_col + prop.tp_len-1)) | 680 - (prop.tp_len != 0))) |
673 start_pos_has_prop = 1; | 681 start_pos_has_prop = 1; |
674 } | |
675 else | |
676 { | |
677 // Not at the first line of the search so adjust col to | |
678 // indicate that we're continuing from prev/next line. | |
679 if (dir < 0) | |
680 col = buf->b_ml.ml_line_len; | |
681 else | |
682 col = 1; | |
683 } | |
684 | 682 |
685 prop_start = !(prop.tp_flags & TP_FLAG_CONT_PREV); | 683 prop_start = !(prop.tp_flags & TP_FLAG_CONT_PREV); |
686 prop_end = !(prop.tp_flags & TP_FLAG_CONT_NEXT); | 684 prop_end = !(prop.tp_flags & TP_FLAG_CONT_NEXT); |
687 if (!prop_start && prop_end && dir > 0) | 685 if (!prop_start && prop_end && dir > 0) |
688 seen_end = 1; | 686 seen_end = 1; |
703 { | 701 { |
704 start_pos_has_prop = 0; | 702 start_pos_has_prop = 0; |
705 break; | 703 break; |
706 } | 704 } |
707 | 705 |
708 if (dir < 0) | |
709 { | |
710 if (col < prop.tp_col) | |
711 break; | |
712 } | |
713 else | |
714 { | |
715 if (col > prop.tp_col + prop.tp_len-1) | |
716 break; | |
717 } | |
718 | |
719 prop_fill_dict(rettv->vval.v_dict, &prop, buf); | 706 prop_fill_dict(rettv->vval.v_dict, &prop, buf); |
720 dict_add_number(rettv->vval.v_dict, "lnum", lnum); | 707 dict_add_number(rettv->vval.v_dict, "lnum", lnum); |
721 | 708 |
722 return; | 709 return; |
723 } | 710 } |
733 { | 720 { |
734 if (lnum <= 1) | 721 if (lnum <= 1) |
735 break; | 722 break; |
736 lnum--; | 723 lnum--; |
737 } | 724 } |
725 // Adjust col to indicate that we're continuing from prev/next line. | |
726 col = dir < 0 ? buf->b_ml.ml_line_len : 1; | |
738 } | 727 } |
739 } | 728 } |
740 | 729 |
741 /* | 730 /* |
742 * prop_list({lnum} [, {bufnr}]) | 731 * prop_list({lnum} [, {bufnr}]) |