aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/edit.c
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2024-02-03 09:42:04 +0800
committerGitHub <noreply@github.com>2024-02-03 09:42:04 +0800
commit1f40b4e22232f22551a9ae89a9f8d59b5ba0c0b6 (patch)
treee4f0777cae588b2274a190b145db539b1b280a6e /src/nvim/edit.c
parentbe1d09c4272212ea9b354c900603568d238b4ab3 (diff)
downloadrneovim-1f40b4e22232f22551a9ae89a9f8d59b5ba0c0b6.tar.gz
rneovim-1f40b4e22232f22551a9ae89a9f8d59b5ba0c0b6.tar.bz2
rneovim-1f40b4e22232f22551a9ae89a9f8d59b5ba0c0b6.zip
vim-patch:9.0.1105: code is indented too much (#27314)
Problem: Code is indented too much. Solution: Use an early return. (Yegappan Lakshmanan, closes vim/vim#11756) https://github.com/vim/vim/commit/87c1cbbe984e60582f2536e4d3c2ce88cd474bb7 Omit free_eval_tofree_later(): Vim9 script only. Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/edit.c')
-rw-r--r--src/nvim/edit.c76
1 files changed, 40 insertions, 36 deletions
diff --git a/src/nvim/edit.c b/src/nvim/edit.c
index 4dcf4d266d..41df039b85 100644
--- a/src/nvim/edit.c
+++ b/src/nvim/edit.c
@@ -1439,45 +1439,47 @@ static int pc_col;
void edit_putchar(int c, bool highlight)
{
- if (curwin->w_grid_alloc.chars != NULL || default_grid.chars != NULL) {
- int attr;
- update_topline(curwin); // just in case w_topline isn't valid
- validate_cursor();
- if (highlight) {
- attr = HL_ATTR(HLF_8);
- } else {
- attr = 0;
- }
- pc_row = curwin->w_wrow;
- pc_status = PC_STATUS_UNSET;
- grid_line_start(&curwin->w_grid, pc_row);
- if (curwin->w_p_rl) {
- pc_col = curwin->w_grid.cols - 1 - curwin->w_wcol;
-
- if (grid_line_getchar(pc_col, NULL) == NUL) {
- grid_line_put_schar(pc_col - 1, schar_from_ascii(' '), attr);
- curwin->w_wcol--;
- pc_status = PC_STATUS_RIGHT;
- }
- } else {
- pc_col = curwin->w_wcol;
+ if (curwin->w_grid_alloc.chars == NULL && default_grid.chars == NULL) {
+ return;
+ }
- if (grid_line_getchar(pc_col + 1, NULL) == NUL) {
- // pc_col is the left half of a double-width char
- pc_status = PC_STATUS_LEFT;
- }
+ int attr;
+ update_topline(curwin); // just in case w_topline isn't valid
+ validate_cursor();
+ if (highlight) {
+ attr = HL_ATTR(HLF_8);
+ } else {
+ attr = 0;
+ }
+ pc_row = curwin->w_wrow;
+ pc_status = PC_STATUS_UNSET;
+ grid_line_start(&curwin->w_grid, pc_row);
+ if (curwin->w_p_rl) {
+ pc_col = curwin->w_grid.cols - 1 - curwin->w_wcol;
+
+ if (grid_line_getchar(pc_col, NULL) == NUL) {
+ grid_line_put_schar(pc_col - 1, schar_from_ascii(' '), attr);
+ curwin->w_wcol--;
+ pc_status = PC_STATUS_RIGHT;
}
+ } else {
+ pc_col = curwin->w_wcol;
- // save the character to be able to put it back
- if (pc_status == PC_STATUS_UNSET) {
- pc_schar = grid_line_getchar(pc_col, &pc_attr);
- pc_status = PC_STATUS_SET;
+ if (grid_line_getchar(pc_col + 1, NULL) == NUL) {
+ // pc_col is the left half of a double-width char
+ pc_status = PC_STATUS_LEFT;
}
+ }
- char buf[MB_MAXCHAR + 1];
- grid_line_puts(pc_col, buf, utf_char2bytes(c, buf), attr);
- grid_line_flush();
+ // save the character to be able to put it back
+ if (pc_status == PC_STATUS_UNSET) {
+ pc_schar = grid_line_getchar(pc_col, &pc_attr);
+ pc_status = PC_STATUS_SET;
}
+
+ char buf[MB_MAXCHAR + 1];
+ grid_line_puts(pc_col, buf, utf_char2bytes(c, buf), attr);
+ grid_line_flush();
}
/// @return the effective prompt for the specified buffer.
@@ -1591,10 +1593,12 @@ void display_dollar(colnr_T col_arg)
// in insert mode.
void undisplay_dollar(void)
{
- if (dollar_vcol >= 0) {
- dollar_vcol = -1;
- redrawWinline(curwin, curwin->w_cursor.lnum);
+ if (dollar_vcol < 0) {
+ return;
}
+
+ dollar_vcol = -1;
+ redrawWinline(curwin, curwin->w_cursor.lnum);
}
/// Insert an indent (for <Tab> or CTRL-T) or delete an indent (for CTRL-D).