mirror of
https://github.com/neovim/neovim.git
synced 2025-10-07 10:26:31 +00:00
refactor: enable formatting for ternaries
This requires removing the "Inner expression should be aligned" rule from clint as it prevents essentially any formatting regarding ternary operators.
This commit is contained in:
@@ -379,8 +379,8 @@ String nvim_cmd(uint64_t channel_id, Dict(cmd) *cmd, Dict(cmd_opts) *opts, Error
|
||||
goto end;
|
||||
});
|
||||
const char *fullname = IS_USER_CMDIDX(ea.cmdidx)
|
||||
? get_user_command_name(ea.useridx, ea.cmdidx)
|
||||
: get_command_name(NULL, ea.cmdidx);
|
||||
? get_user_command_name(ea.useridx, ea.cmdidx)
|
||||
: get_command_name(NULL, ea.cmdidx);
|
||||
VALIDATE(strncmp(fullname, cmdname, strlen(cmdname)) == 0, "Invalid command: \"%s\"", cmdname, {
|
||||
goto end;
|
||||
});
|
||||
@@ -836,8 +836,8 @@ static void build_cmdline_str(char **cmdlinep, exarg_T *eap, CmdParseInfo *cmdin
|
||||
offset += eap->arglens[i];
|
||||
}
|
||||
// If there isn't an argument, make eap->arg point to end of cmdline.
|
||||
eap->arg = argc > 0 ? eap->args[0] :
|
||||
cmdline.items + cmdline.size - 1; // Subtract 1 to account for NUL
|
||||
eap->arg = argc > 0 ? eap->args[0]
|
||||
: cmdline.items + cmdline.size - 1; // Subtract 1 to account for NUL
|
||||
|
||||
// Finally, make cmdlinep point to the cmdline string.
|
||||
*cmdlinep = cmdline.items;
|
||||
|
@@ -689,8 +689,9 @@ static void set_option_to(uint64_t channel_id, void *to, OptReqScope req_scope,
|
||||
|
||||
// For global-win-local options -> setlocal
|
||||
// For win-local options -> setglobal and setlocal (opt_flags == 0)
|
||||
const int opt_flags = (req_scope == kOptReqWin && !(flags & SOPT_GLOBAL)) ? 0 :
|
||||
(req_scope == kOptReqGlobal) ? OPT_GLOBAL : OPT_LOCAL;
|
||||
const int opt_flags = (req_scope == kOptReqWin && !(flags & SOPT_GLOBAL))
|
||||
? 0
|
||||
: (req_scope == kOptReqGlobal) ? OPT_GLOBAL : OPT_LOCAL;
|
||||
|
||||
WITH_SCRIPT_CONTEXT(channel_id, {
|
||||
set_option_value_for(name.data, optval, opt_flags, req_scope, to, err);
|
||||
|
@@ -88,9 +88,9 @@ static int validate_option_value_args(Dict(option) *opts, char *name, int *scope
|
||||
int req_flags = *req_scope == kOptReqBuf ? SOPT_BUF : SOPT_WIN;
|
||||
if (!(flags & req_flags)) {
|
||||
char *tgt = *req_scope & kOptReqBuf ? "buf" : "win";
|
||||
char *global = flags & SOPT_GLOBAL ? "global ": "";
|
||||
char *req = flags & SOPT_BUF ? "buffer-local " :
|
||||
flags & SOPT_WIN ? "window-local " : "";
|
||||
char *global = flags & SOPT_GLOBAL ? "global " : "";
|
||||
char *req = flags & SOPT_BUF ? "buffer-local "
|
||||
: flags & SOPT_WIN ? "window-local " : "";
|
||||
|
||||
api_set_error(err, kErrorTypeValidation, "'%s' cannot be passed for %s%soption '%s'",
|
||||
tgt, global, req, name);
|
||||
@@ -495,7 +495,7 @@ OptVal get_option_value_strict(char *name, OptReqScope req_scope, void *from, Er
|
||||
switchwin_T switchwin;
|
||||
aco_save_T aco;
|
||||
void *ctx = req_scope == kOptReqWin ? (void *)&switchwin
|
||||
: (req_scope == kOptReqBuf ? (void *)&aco : NULL);
|
||||
: (req_scope == kOptReqBuf ? (void *)&aco : NULL);
|
||||
bool switched = switch_option_context(ctx, req_scope, from, err);
|
||||
if (ERROR_SET(err)) {
|
||||
return retv;
|
||||
|
@@ -1301,9 +1301,9 @@ void nvim_subscribe(uint64_t channel_id, String event)
|
||||
void nvim_unsubscribe(uint64_t channel_id, String event)
|
||||
FUNC_API_SINCE(1) FUNC_API_REMOTE_ONLY
|
||||
{
|
||||
size_t length = (event.size < METHOD_MAXLEN ?
|
||||
event.size :
|
||||
METHOD_MAXLEN);
|
||||
size_t length = (event.size < METHOD_MAXLEN
|
||||
? event.size
|
||||
: METHOD_MAXLEN);
|
||||
char e[METHOD_MAXLEN + 1];
|
||||
memcpy(e, event.data, length);
|
||||
e[length] = NUL;
|
||||
@@ -2235,8 +2235,9 @@ Dictionary nvim_eval_statusline(String str, Dict(eval_statusline) *opts, Error *
|
||||
maxwidth = (int)opts->maxwidth;
|
||||
} else {
|
||||
maxwidth = statuscol_lnum ? win_col_off(wp)
|
||||
: (opts->use_tabline
|
||||
|| (!opts->use_winbar && global_stl_height() > 0)) ? Columns : wp->w_width;
|
||||
: (opts->use_tabline
|
||||
|| (!opts->use_winbar
|
||||
&& global_stl_height() > 0)) ? Columns : wp->w_width;
|
||||
}
|
||||
|
||||
char buf[MAXPATHL];
|
||||
|
Reference in New Issue
Block a user