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

Code before:
{
  // When getting the ATTENTION prompt here, use a dialog.
  swap_exists_action = SEA_DIALOG;
  no_wait_return = true;
  bool save_msg_didany = msg_didany;
  buf_T *prev_buf = NULL;

  if (curbuf->b_ffname) {
    // curbuf is already opened for a file, create a new buffer for stdin #35269
    buf_T *newbuf = buflist_new(NULL, NULL, 0, 0);
    if (newbuf == NULL) {
      ELOG("Unable to allocate buffer for stdin");
      return;
    }

    // remember the current buffer so we can go back to it
    prev_buf = curbuf;
    set_curbuf(newbuf, 0, false);
  }

  set_buflisted(true);
  // Create memfile and read from stdin.
  open_buffer(true, NULL, 0);
  if (buf_is_empty(curbuf)) {
    // stdin was empty so we should wipe it (e.g. "echo file1 | xargs nvim"). #8561
    // stdin buffer may be first or last #35269
    if ((curbuf->b_next != NULL) || (curbuf->b_prev != NULL)) {
      do_bufdel(DOBUF_WIPE, NULL, 0, 0, 0, 1);
    }
  }

  // we had to switch buffers to load stdin, switch back
  if (prev_buf) {
    set_curbuf(prev_buf, 0, false);
  }

  no_wait_return = false;
  msg_didany = save_msg_didany;
  TIME_MSG("reading stdin");
  check_swap_exists_action();
}

// Create the requested number of windows and edit buffers in them.
// Also does recovery if "recoverymode" set.
static void create_windows(mparm_T *parmp)
{
  // Create the number of windows that was requested.
  if (parmp->window_count == -1) {      // was not set
    parmp->window_count = 1;
  }
  if (parmp->window_count == 0) {

Review comment (suggestion):
```suggestion
    // stdin buffer may be first or last ("echo foo | nvim file1 -"). #35269
```

Code after:
{
  // When getting the ATTENTION prompt here, use a dialog.
  swap_exists_action = SEA_DIALOG;
  no_wait_return = true;
  bool save_msg_didany = msg_didany;
  buf_T *prev_buf = NULL;

  if (curbuf->b_ffname) {
    // curbuf is already opened for a file, create a new buffer for stdin. #35269
    buf_T *newbuf = buflist_new(NULL, NULL, 0, 0);
    if (newbuf == NULL) {
      semsg("Failed to create buffer for stdin");
      return;
    }

    // remember the current buffer so we can go back to it
    prev_buf = curbuf;
    set_curbuf(newbuf, 0, false);
  }

  set_buflisted(true);
  // Create memfile and read from stdin.
  open_buffer(true, NULL, 0);
  if (buf_is_empty(curbuf)) {
    // stdin was empty so we should wipe it (e.g. "echo file1 | xargs nvim"). #8561
    // stdin buffer may be first or last ("echo foo | nvim file1 -"). #35269
    if ((curbuf->b_next != NULL) || (curbuf->b_prev != NULL)) {
      do_bufdel(DOBUF_WIPE, NULL, 0, 0, 0, 1);
    }
  }

  // we had to switch buffers to load stdin, switch back
  if (prev_buf) {
    set_curbuf(prev_buf, 0, false);
  }

  no_wait_return = false;
  msg_didany = save_msg_didany;
  TIME_MSG("reading stdin");
  check_swap_exists_action();
}

// Create the requested number of windows and edit buffers in them.
// Also does recovery if "recoverymode" set.
static void create_windows(mparm_T *parmp)
{
  // Create the number of windows that was requested.
  if (parmp->window_count == -1) {      // was not set
    parmp->window_count = 1;
  }
  if (parmp->window_count == 0) {