aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/cursor.c
diff options
context:
space:
mode:
authorbfredl <bjorn.linse@gmail.com>2023-08-24 23:12:26 +0200
committerGitHub <noreply@github.com>2023-08-24 23:12:26 +0200
commit5b4f1f56c350995521aafa60419b93708de80fd9 (patch)
tree146d6cb8fde01d28c5b03b9640f9e2515c4a89b7 /src/nvim/cursor.c
parentdaf7abbc4238dc269e22dd431bc4b1627ef9b6a1 (diff)
parentcefd774fac76b91f5368833555818c80c992c3b1 (diff)
downloadrneovim-5b4f1f56c350995521aafa60419b93708de80fd9.tar.gz
rneovim-5b4f1f56c350995521aafa60419b93708de80fd9.tar.bz2
rneovim-5b4f1f56c350995521aafa60419b93708de80fd9.zip
Merge pull request #24862 from bfredl/ml_get_buf
refactor(memline): distinguish mutating uses of ml_get_buf()
Diffstat (limited to 'src/nvim/cursor.c')
-rw-r--r--src/nvim/cursor.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/src/nvim/cursor.c b/src/nvim/cursor.c
index a837618f5b..f7a456f4c7 100644
--- a/src/nvim/cursor.c
+++ b/src/nvim/cursor.c
@@ -108,7 +108,7 @@ static int coladvance2(pos_T *pos, bool addspaces, bool finetune, colnr_T wcol_a
|| (VIsual_active && *p_sel != 'o')
|| ((get_ve_flags() & VE_ONEMORE) && wcol < MAXCOL);
- char *line = ml_get_buf(curbuf, pos->lnum, false);
+ char *line = ml_get_buf(curbuf, pos->lnum);
if (wcol >= MAXCOL) {
idx = (int)strlen(line) - 1 + one_more;
@@ -315,7 +315,7 @@ void check_pos(buf_T *buf, pos_T *pos)
}
if (pos->col > 0) {
- char *line = ml_get_buf(buf, pos->lnum, false);
+ char *line = ml_get_buf(buf, pos->lnum);
colnr_T len = (colnr_T)strlen(line);
if (pos->col > len) {
pos->col = len;
@@ -353,7 +353,7 @@ void check_cursor_col_win(win_T *win)
colnr_T oldcoladd = win->w_cursor.col + win->w_cursor.coladd;
unsigned cur_ve_flags = get_ve_flags();
- colnr_T len = (colnr_T)strlen(ml_get_buf(win->w_buffer, win->w_cursor.lnum, false));
+ colnr_T len = (colnr_T)strlen(ml_get_buf(win->w_buffer, win->w_cursor.lnum));
if (len == 0) {
win->w_cursor.col = 0;
} else if (win->w_cursor.col >= len) {
@@ -501,18 +501,17 @@ int gchar_cursor(void)
/// It is directly written into the block.
void pchar_cursor(char c)
{
- *(ml_get_buf(curbuf, curwin->w_cursor.lnum, true)
- + curwin->w_cursor.col) = c;
+ *(ml_get_buf_mut(curbuf, curwin->w_cursor.lnum) + curwin->w_cursor.col) = c;
}
/// @return pointer to cursor line.
char *get_cursor_line_ptr(void)
{
- return ml_get_buf(curbuf, curwin->w_cursor.lnum, false);
+ return ml_get_buf(curbuf, curwin->w_cursor.lnum);
}
/// @return pointer to cursor position.
char *get_cursor_pos_ptr(void)
{
- return ml_get_buf(curbuf, curwin->w_cursor.lnum, false) + curwin->w_cursor.col;
+ return ml_get_buf(curbuf, curwin->w_cursor.lnum) + curwin->w_cursor.col;
}