aboutsummaryrefslogtreecommitdiff
path: root/src/nvim/ops.c
diff options
context:
space:
mode:
authordundargoc <33953936+dundargoc@users.noreply.github.com>2021-09-17 16:38:16 +0200
committerGitHub <noreply@github.com>2021-09-17 07:38:16 -0700
commit867e8885991ae450019c18aa5e42546bd4b62c2c (patch)
treef130aaed5d3f46ce994871efad7e33f3dd3ef9b8 /src/nvim/ops.c
parent1ec3d37192194d6961621f17fc5a185356586339 (diff)
downloadrneovim-867e8885991ae450019c18aa5e42546bd4b62c2c.tar.gz
rneovim-867e8885991ae450019c18aa5e42546bd4b62c2c.tar.bz2
rneovim-867e8885991ae450019c18aa5e42546bd4b62c2c.zip
refactor(style): switch-case formatting, "uncrustify:indent-off" #15669
* refactor: disable formatting for attribute in macro * fixup: disable/enable uncrustify with uncrustify:indent-off/on * fixup: stop indenting contents inside braces in case * fixup: remove case brace if no variable declaration
Diffstat (limited to 'src/nvim/ops.c')
-rw-r--r--src/nvim/ops.c144
1 files changed, 70 insertions, 74 deletions
diff --git a/src/nvim/ops.c b/src/nvim/ops.c
index a0dee7ace8..10a099eb47 100644
--- a/src/nvim/ops.c
+++ b/src/nvim/ops.c
@@ -2622,64 +2622,64 @@ static void op_yank_reg(oparg_T *oap, bool message, yankreg_T *reg, bool append)
break;
case kMTCharWise: {
- colnr_T startcol = 0, endcol = MAXCOL;
- int is_oneChar = false;
- colnr_T cs, ce;
- p = ml_get(lnum);
- bd.startspaces = 0;
- bd.endspaces = 0;
-
- if (lnum == oap->start.lnum) {
- startcol = oap->start.col;
- if (virtual_op) {
- getvcol(curwin, &oap->start, &cs, NULL, &ce);
- if (ce != cs && oap->start.coladd > 0) {
- /* Part of a tab selected -- but don't
- * double-count it. */
- bd.startspaces = (ce - cs + 1)
- - oap->start.coladd;
- startcol++;
- }
+ colnr_T startcol = 0, endcol = MAXCOL;
+ int is_oneChar = false;
+ colnr_T cs, ce;
+ p = ml_get(lnum);
+ bd.startspaces = 0;
+ bd.endspaces = 0;
+
+ if (lnum == oap->start.lnum) {
+ startcol = oap->start.col;
+ if (virtual_op) {
+ getvcol(curwin, &oap->start, &cs, NULL, &ce);
+ if (ce != cs && oap->start.coladd > 0) {
+ /* Part of a tab selected -- but don't
+ * double-count it. */
+ bd.startspaces = (ce - cs + 1)
+ - oap->start.coladd;
+ startcol++;
}
}
+ }
- if (lnum == oap->end.lnum) {
- endcol = oap->end.col;
- if (virtual_op) {
- getvcol(curwin, &oap->end, &cs, NULL, &ce);
- if (p[endcol] == NUL || (cs + oap->end.coladd < ce
- // Don't add space for double-wide
- // char; endcol will be on last byte
- // of multi-byte char.
- && utf_head_off(p, p + endcol) == 0)) {
- if (oap->start.lnum == oap->end.lnum
- && oap->start.col == oap->end.col) {
- // Special case: inside a single char
- is_oneChar = true;
- bd.startspaces = oap->end.coladd
- - oap->start.coladd + oap->inclusive;
- endcol = startcol;
- } else {
- bd.endspaces = oap->end.coladd
- + oap->inclusive;
- endcol -= oap->inclusive;
- }
+ if (lnum == oap->end.lnum) {
+ endcol = oap->end.col;
+ if (virtual_op) {
+ getvcol(curwin, &oap->end, &cs, NULL, &ce);
+ if (p[endcol] == NUL || (cs + oap->end.coladd < ce
+ // Don't add space for double-wide
+ // char; endcol will be on last byte
+ // of multi-byte char.
+ && utf_head_off(p, p + endcol) == 0)) {
+ if (oap->start.lnum == oap->end.lnum
+ && oap->start.col == oap->end.col) {
+ // Special case: inside a single char
+ is_oneChar = true;
+ bd.startspaces = oap->end.coladd
+ - oap->start.coladd + oap->inclusive;
+ endcol = startcol;
+ } else {
+ bd.endspaces = oap->end.coladd
+ + oap->inclusive;
+ endcol -= oap->inclusive;
}
}
}
- if (endcol == MAXCOL) {
- endcol = (colnr_T)STRLEN(p);
- }
- if (startcol > endcol
- || is_oneChar) {
- bd.textlen = 0;
- } else {
- bd.textlen = endcol - startcol + oap->inclusive;
- }
- bd.textstart = p + startcol;
- yank_copy_line(reg, &bd, y_idx, false);
- break;
}
+ if (endcol == MAXCOL) {
+ endcol = (colnr_T)STRLEN(p);
+ }
+ if (startcol > endcol
+ || is_oneChar) {
+ bd.textlen = 0;
+ } else {
+ bd.textlen = endcol - startcol + oap->inclusive;
+ }
+ bd.textstart = p + startcol;
+ yank_copy_line(reg, &bd, y_idx, false);
+ break;
+ }
// NOTREACHED
case kMTUnknown:
abort();
@@ -5781,15 +5781,15 @@ void cursor_pos_info(dict_T *dict)
len = MAXCOL;
break;
case 'v': {
- colnr_T start_col = (lnum == min_pos.lnum)
+ colnr_T start_col = (lnum == min_pos.lnum)
? min_pos.col : 0;
- colnr_T end_col = (lnum == max_pos.lnum)
+ colnr_T end_col = (lnum == max_pos.lnum)
? max_pos.col - start_col + 1 : MAXCOL;
- s = ml_get(lnum) + start_col;
- len = end_col;
- }
- break;
+ s = ml_get(lnum) + start_col;
+ len = end_col;
+ }
+ break;
}
if (s != NULL) {
byte_count_cursor += line_count_info(s, &word_count_cursor,
@@ -6221,23 +6221,19 @@ static void set_clipboard(int name, yankreg_T *reg)
char regtype;
switch (reg->y_type) {
- case kMTLineWise: {
- regtype = 'V';
- tv_list_append_string(lines, NULL, 0);
- break;
- }
- case kMTCharWise: {
- regtype = 'v';
- break;
- }
- case kMTBlockWise: {
- regtype = 'b';
- tv_list_append_string(lines, NULL, 0);
- break;
- }
- case kMTUnknown: {
- abort();
- }
+ case kMTLineWise:
+ regtype = 'V';
+ tv_list_append_string(lines, NULL, 0);
+ break;
+ case kMTCharWise:
+ regtype = 'v';
+ break;
+ case kMTBlockWise:
+ regtype = 'b';
+ tv_list_append_string(lines, NULL, 0);
+ break;
+ case kMTUnknown:
+ abort();
}
list_T *args = tv_list_alloc(3);