Mercurial > vim
comparison src/ops.c @ 2289:3331756e4232 vim73
Make synstack() work on the character just after the end of the line.
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Thu, 08 Jul 2010 22:27:55 +0200 |
parents | 0b3be97064e5 |
children | 2209060c340d |
comparison
equal
deleted
inserted
replaced
2288:4dda2bd944e1 | 2289:3331756e4232 |
---|---|
1593 *rp = 0; | 1593 *rp = 0; |
1594 } | 1594 } |
1595 #endif | 1595 #endif |
1596 | 1596 |
1597 /* | 1597 /* |
1598 * op_delete - handle a delete operation | 1598 * Handle a delete operation. |
1599 * | 1599 * |
1600 * return FAIL if undo failed, OK otherwise. | 1600 * Return FAIL if undo failed, OK otherwise. |
1601 */ | 1601 */ |
1602 int | 1602 int |
1603 op_delete(oap) | 1603 op_delete(oap) |
1604 oparg_T *oap; | 1604 oparg_T *oap; |
1605 { | 1605 { |
1633 #ifdef FEAT_MBYTE | 1633 #ifdef FEAT_MBYTE |
1634 if (has_mbyte) | 1634 if (has_mbyte) |
1635 mb_adjust_opend(oap); | 1635 mb_adjust_opend(oap); |
1636 #endif | 1636 #endif |
1637 | 1637 |
1638 /* | 1638 /* |
1639 * Imitate the strange Vi behaviour: If the delete spans more than one line | 1639 * Imitate the strange Vi behaviour: If the delete spans more than one |
1640 * and motion_type == MCHAR and the result is a blank line, make the delete | 1640 * line and motion_type == MCHAR and the result is a blank line, make the |
1641 * linewise. Don't do this for the change command or Visual mode. | 1641 * delete linewise. Don't do this for the change command or Visual mode. |
1642 */ | 1642 */ |
1643 if ( oap->motion_type == MCHAR | 1643 if ( oap->motion_type == MCHAR |
1644 #ifdef FEAT_VISUAL | 1644 #ifdef FEAT_VISUAL |
1645 && !oap->is_VIsual | 1645 && !oap->is_VIsual |
1646 && !oap->block_mode | 1646 && !oap->block_mode |
1647 #endif | 1647 #endif |
1652 ptr = skipwhite(ptr); | 1652 ptr = skipwhite(ptr); |
1653 if (*ptr == NUL && inindent(0)) | 1653 if (*ptr == NUL && inindent(0)) |
1654 oap->motion_type = MLINE; | 1654 oap->motion_type = MLINE; |
1655 } | 1655 } |
1656 | 1656 |
1657 /* | 1657 /* |
1658 * Check for trying to delete (e.g. "D") in an empty line. | 1658 * Check for trying to delete (e.g. "D") in an empty line. |
1659 * Note: For the change operator it is ok. | 1659 * Note: For the change operator it is ok. |
1660 */ | 1660 */ |
1661 if ( oap->motion_type == MCHAR | 1661 if ( oap->motion_type == MCHAR |
1662 && oap->line_count == 1 | 1662 && oap->line_count == 1 |
1663 && oap->op_type == OP_DELETE | 1663 && oap->op_type == OP_DELETE |
1664 && *ml_get(oap->start.lnum) == NUL) | 1664 && *ml_get(oap->start.lnum) == NUL) |
1665 { | 1665 { |
1676 if (vim_strchr(p_cpo, CPO_EMPTYREGION) != NULL) | 1676 if (vim_strchr(p_cpo, CPO_EMPTYREGION) != NULL) |
1677 beep_flush(); | 1677 beep_flush(); |
1678 return OK; | 1678 return OK; |
1679 } | 1679 } |
1680 | 1680 |
1681 /* | 1681 /* |
1682 * Do a yank of whatever we're about to delete. | 1682 * Do a yank of whatever we're about to delete. |
1683 * If a yank register was specified, put the deleted text into that register. | 1683 * If a yank register was specified, put the deleted text into that |
1684 * For the black hole register '_' don't yank anything. | 1684 * register. For the black hole register '_' don't yank anything. |
1685 */ | 1685 */ |
1686 if (oap->regname != '_') | 1686 if (oap->regname != '_') |
1687 { | 1687 { |
1688 if (oap->regname != 0) | 1688 if (oap->regname != 0) |
1689 { | 1689 { |
1690 /* check for read-only register */ | 1690 /* check for read-only register */ |
1747 } | 1747 } |
1748 } | 1748 } |
1749 } | 1749 } |
1750 | 1750 |
1751 #ifdef FEAT_VISUAL | 1751 #ifdef FEAT_VISUAL |
1752 /* | 1752 /* |
1753 * block mode delete | 1753 * block mode delete |
1754 */ | 1754 */ |
1755 if (oap->block_mode) | 1755 if (oap->block_mode) |
1756 { | 1756 { |
1757 if (u_save((linenr_T)(oap->start.lnum - 1), | 1757 if (u_save((linenr_T)(oap->start.lnum - 1), |
1758 (linenr_T)(oap->end.lnum + 1)) == FAIL) | 1758 (linenr_T)(oap->end.lnum + 1)) == FAIL) |
1759 return FAIL; | 1759 return FAIL; |