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

Code before:
  const bool save_ex_pressedreturn = ex_pressedreturn;
  // parsing the command range may require moving the cursor
  const pos_T save_cursor = curwin->w_cursor;
  // parsing the command range may set the last search pattern
  save_last_search_pattern();

  // Initialize cmdinfo
  CLEAR_POINTER(cmdinfo);

  // Initialize eap
  *eap = (exarg_T){
    .line1 = 1,
    .line2 = 1,
    .cmd = *cmdline,
    .cmdlinep = cmdline,
    .ea_getline = NULL,
    .cookie = NULL,
  };

  // Parse command modifiers
  if (parse_command_modifiers(eap, errormsg, &cmdinfo->cmdmod, false) == FAIL) {
    goto end;
  }
  after_modifier = eap->cmd;

  // Find command name after any range specification
  char *p = find_command_after_range(eap);
  if (p == NULL) {
    *errormsg = _(e_ambiguous_use_of_user_defined_command);
    goto end;
  }

  // Set command address type and parse command range
  set_cmd_addr_type(eap, p);
  if (parse_cmd_address(eap, errormsg, true) == FAIL) {
    goto end;
  }

  // Skip colon and whitespace
  eap->cmd = skip_colon_white(eap->cmd, true);
  // Fail if command is a comment or if command doesn't exist
  if (*eap->cmd == NUL || *eap->cmd == '"') {
    goto end;
  }
  // Fail if command is invalid
  if (eap->cmdidx == CMD_SIZE) {
    xstrlcpy(IObuff, _(e_not_an_editor_command), IOSIZE);
    // If the modifier was parsed OK the error must be in the following command
    char *cmdname = after_modifier ? after_modifier : *cmdline;
    append_command(cmdname);
    *errormsg = IObuff;

Review comment (suggestion):
```suggestion
  // We need the command name to know what kind of range it uses.
```

Code after:
  bool retval = false;
  // parsing the command modifiers may set ex_pressedreturn
  const bool save_ex_pressedreturn = ex_pressedreturn;
  // parsing the command range may require moving the cursor
  const pos_T save_cursor = curwin->w_cursor;
  // parsing the command range may set the last search pattern
  save_last_search_pattern();

  // Initialize cmdinfo
  CLEAR_POINTER(cmdinfo);

  // Initialize eap
  *eap = (exarg_T){
    .line1 = 1,
    .line2 = 1,
    .cmd = *cmdline,
    .cmdlinep = cmdline,
    .ea_getline = NULL,
    .cookie = NULL,
  };

  // Parse command modifiers
  if (parse_command_modifiers(eap, errormsg, &cmdinfo->cmdmod, false) == FAIL) {
    goto end;
  }
  after_modifier = eap->cmd;

  // We need the command name to know what kind of range it uses.
  char *p = find_excmd_after_range(eap);
  if (p == NULL) {
    *errormsg = _(e_ambiguous_use_of_user_defined_command);
    goto end;
  }

  // Set command address type and parse command range
  set_cmd_addr_type(eap, p);
  if (parse_cmd_address(eap, errormsg, true) == FAIL) {
    goto end;
  }

  // Skip colon and whitespace
  eap->cmd = skip_colon_white(eap->cmd, true);
  // Fail if command is a comment or if command doesn't exist
  if (*eap->cmd == NUL || *eap->cmd == '"') {
    goto end;
  }
  // Fail if command is invalid
  if (eap->cmdidx == CMD_SIZE) {
    xstrlcpy(IObuff, _(e_not_an_editor_command), IOSIZE);
    // If the modifier was parsed OK the error must be in the following command
    char *cmdname = after_modifier ? after_modifier : *cmdline;