diff options
author | Daniel Hahler <git@thequod.de> | 2019-06-10 14:59:32 +0200 |
---|---|---|
committer | Daniel Hahler <git@thequod.de> | 2019-08-07 14:21:23 +0200 |
commit | be08d52e1119b58b9e7a49343d8a6c64eefe4fdb (patch) | |
tree | cc500fbcce7771f31dc5631da578eeaefe6152b5 /src | |
parent | 33e6cffb9b5130b67ebc0a56df143ce40ce4c127 (diff) | |
download | rneovim-be08d52e1119b58b9e7a49343d8a6c64eefe4fdb.tar.gz rneovim-be08d52e1119b58b9e7a49343d8a6c64eefe4fdb.tar.bz2 rneovim-be08d52e1119b58b9e7a49343d8a6c64eefe4fdb.zip |
move truncate_line
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/change.c | 44 | ||||
-rw-r--r-- | src/nvim/misc1.c | 30 |
2 files changed, 20 insertions, 54 deletions
diff --git a/src/nvim/change.c b/src/nvim/change.c index 5ca97277fd..0273c6fa33 100644 --- a/src/nvim/change.c +++ b/src/nvim/change.c @@ -1749,35 +1749,31 @@ theend: /* * Delete from cursor to end of line. * Caller must have prepared for undo. - * If "fixpos" is TRUE fix the cursor position when done. - * - * Return FAIL for failure, OK otherwise. */ - int -truncate_line(int fixpos) +void +truncate_line ( + int fixpos /* if TRUE fix the cursor position when done */ +) { - char_u *newp; - linenr_T lnum = curwin->w_cursor.lnum; - colnr_T col = curwin->w_cursor.col; - - if (col == 0) - newp = vim_strsave((char_u *)""); - else - newp = vim_strnsave(ml_get(lnum), col); - - if (newp == NULL) - return FAIL; - - ml_replace(lnum, newp, FALSE); + char_u *newp; + linenr_T lnum = curwin->w_cursor.lnum; + colnr_T col = curwin->w_cursor.col; - // mark the buffer as changed and prepare for displaying - changed_bytes(lnum, curwin->w_cursor.col); + if (col == 0) { + newp = vim_strsave((char_u *)""); + } else { + newp = vim_strnsave(ml_get(lnum), (size_t)col); + } + ml_replace(lnum, newp, false); - // If "fixpos" is TRUE we don't want to end up positioned at the NUL. - if (fixpos && curwin->w_cursor.col > 0) - --curwin->w_cursor.col; + /* mark the buffer as changed and prepare for displaying */ + changed_bytes(lnum, curwin->w_cursor.col); - return OK; + /* + * If "fixpos" is TRUE we don't want to end up positioned at the NUL. + */ + if (fixpos && curwin->w_cursor.col > 0) + --curwin->w_cursor.col; } /* diff --git a/src/nvim/misc1.c b/src/nvim/misc1.c index a7d3cb9bba..5cd2f778a0 100644 --- a/src/nvim/misc1.c +++ b/src/nvim/misc1.c @@ -526,36 +526,6 @@ void ins_char(int c) } /* - * Delete from cursor to end of line. - * Caller must have prepared for undo. - */ -void -truncate_line ( - int fixpos /* if TRUE fix the cursor position when done */ -) -{ - char_u *newp; - linenr_T lnum = curwin->w_cursor.lnum; - colnr_T col = curwin->w_cursor.col; - - if (col == 0) { - newp = vim_strsave((char_u *)""); - } else { - newp = vim_strnsave(ml_get(lnum), (size_t)col); - } - ml_replace(lnum, newp, false); - - /* mark the buffer as changed and prepare for displaying */ - changed_bytes(lnum, curwin->w_cursor.col); - - /* - * If "fixpos" is TRUE we don't want to end up positioned at the NUL. - */ - if (fixpos && curwin->w_cursor.col > 0) - --curwin->w_cursor.col; -} - -/* * Delete "nlines" lines at the cursor. * Saves the lines for undo first if "undo" is TRUE. */ |