comparison src/memline.c @ 17425:6580e2dfcaeb v8.1.1711

patch 8.1.1711: listener callback called at the wrong moment commit https://github.com/vim/vim/commit/acf7544cf62227972eeb063d6d9ecddaa5682a73 Author: Bram Moolenaar <Bram@vim.org> Date: Wed Jul 17 22:55:35 2019 +0200 patch 8.1.1711: listener callback called at the wrong moment Problem: Listener callback called at the wrong moment Solution: Invoke listeners before calling ml_delete_int(). (closes https://github.com/vim/vim/issues/4657)
author Bram Moolenaar <Bram@vim.org>
date Wed, 17 Jul 2019 23:00:06 +0200
parents 9b6c0ef29c20
children 37afc0146eab
comparison
equal deleted inserted replaced
17424:bc21f0261afb 17425:6580e2dfcaeb
3564 */ 3564 */
3565 int 3565 int
3566 ml_delete(linenr_T lnum, int message) 3566 ml_delete(linenr_T lnum, int message)
3567 { 3567 {
3568 ml_flush_line(curbuf); 3568 ml_flush_line(curbuf);
3569 if (lnum < 1 || lnum > curbuf->b_ml.ml_line_count)
3570 return FAIL;
3571
3572 #ifdef FEAT_EVAL
3573 // When inserting above recorded changes: flush the changes before changing
3574 // the text.
3575 may_invoke_listeners(curbuf, lnum, lnum + 1, -1);
3576 #endif
3577
3569 return ml_delete_int(curbuf, lnum, message); 3578 return ml_delete_int(curbuf, lnum, message);
3570 } 3579 }
3571 3580
3572 static int 3581 static int
3573 ml_delete_int(buf_T *buf, linenr_T lnum, int message) 3582 ml_delete_int(buf_T *buf, linenr_T lnum, int message)
3588 #ifdef FEAT_TEXT_PROP 3597 #ifdef FEAT_TEXT_PROP
3589 char_u *textprop_save = NULL; 3598 char_u *textprop_save = NULL;
3590 int textprop_save_len; 3599 int textprop_save_len;
3591 #endif 3600 #endif
3592 3601
3593 if (lnum < 1 || lnum > buf->b_ml.ml_line_count)
3594 return FAIL;
3595
3596 #ifdef FEAT_EVAL
3597 // When inserting above recorded changes: flush the changes before changing
3598 // the text.
3599 may_invoke_listeners(buf, lnum, lnum + 1, -1);
3600 #endif
3601 if (lowest_marked && lowest_marked > lnum) 3602 if (lowest_marked && lowest_marked > lnum)
3602 lowest_marked--; 3603 lowest_marked--;
3603 3604
3604 /* 3605 /*
3605 * If the file becomes empty the last line is replaced by an empty line. 3606 * If the file becomes empty the last line is replaced by an empty line.