Repository: neovim/neovim
File: src/nvim/change.c (C)

Code before:
                    - (newindent + (int)strlen(leader));

      // Here whitespace is inserted after the comment char.
      // Below, set_indent(newindent, SIN_INSERT) will insert the
      // whitespace needed before the comment char.
      for (int i = 0; i < padding; i++) {
        strcat(leader, " ");
        less_cols--;
        newcol++;
      }
    }
    strcat(leader, p_extra);
    p_extra = leader;
    did_ai = true;          // So truncating blanks works with comments
    less_cols -= lead_len;
  } else {
    end_comment_pending = NUL;  // turns out there was no leader
  }

  curbuf_splice_pending++;
  old_cursor = curwin->w_cursor;
  int old_cmod_flags = cmdmod.cmod_flags;
  char *prompt_moved = NULL;
  if (dir == BACKWARD) {
    if (bt_prompt(curbuf)
        && curwin->w_cursor.lnum == curbuf->b_prompt_submitted.mark.lnum) {
      char *prompt_line = ml_get(curwin->w_cursor.lnum);
      char *prompt = prompt_text();
      size_t prompt_len = strlen(prompt);

      if (strncmp(prompt_line, prompt, prompt_len) == 0) {
        STRMOVE(prompt_line, prompt_line + prompt_len);
        cmdmod.cmod_flags = cmdmod.cmod_flags | CMOD_LOCKMARKS;
        ml_replace(curwin->w_cursor.lnum, prompt_line, true);
        prompt_moved = concat_str(prompt, p_extra);
        p_extra = prompt_moved;
      }
    }
    curwin->w_cursor.lnum--;
  }
  if ((State & VREPLACE_FLAG) == 0 || old_cursor.lnum >= orig_line_count) {
    if (ml_append(curwin->w_cursor.lnum, p_extra, 0, false) == FAIL) {
      goto theend;
    }
    // Postpone calling changed_lines(), because it would mess up folding
    // with markers.
    mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1, 0, kExtmarkNOOP);
    did_append = true;
  } else {
    // In MODE_VREPLACE state we are starting to replace the next line.
    curwin->w_cursor.lnum++;

Review comment (suggestion):
1-line comment that gives a hint about what this block does?

```suggestion
    // ...
    if (bt_prompt(curbuf) && curwin->w_cursor.lnum == curbuf->b_prompt_submitted.mark.lnum) {
```

Code after:
                    - (newindent + (int)strlen(leader));

      // Here whitespace is inserted after the comment char.
      // Below, set_indent(newindent, SIN_INSERT) will insert the
      // whitespace needed before the comment char.
      for (int i = 0; i < padding; i++) {
        strcat(leader, " ");
        less_cols--;
        newcol++;
      }
    }
    strcat(leader, p_extra);
    p_extra = leader;
    did_ai = true;          // So truncating blanks works with comments
    less_cols -= lead_len;
  } else {
    end_comment_pending = NUL;  // turns out there was no leader
  }

  curbuf_splice_pending++;
  old_cursor = curwin->w_cursor;
  int old_cmod_flags = cmdmod.cmod_flags;
  char *prompt_moved = NULL;
  if (dir == BACKWARD) {
    // In case of prompt buffer, when we are applying 'normal O' operation on line of prompt,
    // we can't add a new line before the prompt. In this case, we move the prompt text one
    // line below and create a new prompt line as current line.
    if (bt_prompt(curbuf) && curwin->w_cursor.lnum == curbuf->b_prompt_start.mark.lnum) {
      char *prompt_line = ml_get(curwin->w_cursor.lnum);
      char *prompt = prompt_text();
      size_t prompt_len = strlen(prompt);

      if (strncmp(prompt_line, prompt, prompt_len) == 0) {
        STRMOVE(prompt_line, prompt_line + prompt_len);
        // We are moving the lines but the b_prompt_start mark needs to stay in
        // place so freezing marks before making the move.
        cmdmod.cmod_flags = cmdmod.cmod_flags | CMOD_LOCKMARKS;
        ml_replace(curwin->w_cursor.lnum, prompt_line, true);
        prompt_moved = concat_str(prompt, p_extra);
        p_extra = prompt_moved;
      }
    }
    curwin->w_cursor.lnum--;
  }
  if ((State & VREPLACE_FLAG) == 0 || old_cursor.lnum >= orig_line_count) {
    if (ml_append(curwin->w_cursor.lnum, p_extra, 0, false) == FAIL) {
      goto theend;
    }
    // Postpone calling changed_lines(), because it would mess up folding
    // with markers.
    mark_adjust(curwin->w_cursor.lnum + 1, (linenr_T)MAXLNUM, 1, 0, kExtmarkNOOP);