Skip to content

Conversation

blueyed
Copy link
Contributor

@blueyed blueyed commented Mar 25, 2019

No description provided.

blueyed added 4 commits March 25, 2019 12:43
This goes well together with the previous commit.

Vim uses this internally since it has a hard width of 2 cells for the
signcolumn, but that has changed in Neovim now.
}
}

if (nr_signs > 0 && buf->b_signcols_max < same) {
buf->b_signcols_max = same;
buf->b_signcols_cells = cells;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This loop should be made clearer probably.

@@ -5899,7 +5899,7 @@ comp_textwidth (
textwidth -= 1;
}
textwidth -= curwin->w_p_fdc;
textwidth -= win_signcol_count(curwin);
textwidth -= win_signcol_width(curwin);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should/could address the buffer value directly probably for performance reasons.

if (cells == 1) {
STRCPY(sp->sn_text + len - 1, " ");
}
sp->sn_text = vim_strnsave(arg, p - arg);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is in a separate commit - not strictly necessary, but allows for having signs only take one cell after all.

@@ -3035,6 +3035,8 @@ did_set_string_option (
// 'signcolumn'
if (check_opt_strings(*varp, p_scl_values, false) != OK) {
errmsg = e_invarg;
} else {
curwin->w_buffer->b_signcols_max = -1;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Invalidates the cache - could need a comment maybe. But it is done like this in many places already.

Copy link
Member

@justinmk justinmk Mar 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

probably need #define SIGNCOLS_UNKNOWN -1 in sign_defs.h by now.

if (cols) {
return MAX(cols, wp->w_buffer->b_signcols_cells);
}
return 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was quick and dirty.
Any idea how to improve this? (not having two functions)

p_extra = extra;
p_extra[n_extra] = NUL;
n_extra = (int)STRLEN(p_extra);
sign_cells -= mb_string2cells(p_extra);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous use of extra was not clear to me. Using just p_extra and n_extra seems to be good, no?
/cc @teto (via 0848add).

@@ -781,6 +781,7 @@ struct file_buffer {
signlist_T *b_signlist; // list of signs to draw
int b_signcols_max; // cached maximum number of sign columns
int b_signcols; // last calculated number of sign columns
int b_signcols_cells; // number of cells used for sign columns
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we need another field (and thus all the associated housekeeping)? why can't this replace b_signcols?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

count != cols, max/b_signcols holds the count.
https://github.com/blueyed/neovim/blob/6d5f8c7addcc4b276a436531e75cb3b620fe513e/src/nvim/buffer.c#L5163-L5167
But it certainly should at least use "cols" (effective).
I might be missing something here though.

@justinmk
Copy link
Member

cc @da-x

@blueyed
Copy link
Contributor Author

blueyed commented Mar 25, 2019

So one test is failing, but I cannot reproduce it (likely because the real UI does not allow to move the cursor there?!):

[  ERROR   ] test/functional/ui/sign_spec.lua @ 118: Signs :sign place multiple signs #9295
test/functional/ui/screen.lua:560: Row 4 did not match.
Expected:
  |{1:>>}XX{6:  1 }a                                            |
  |XX{1:>>}{6:  2 }b                                            |
  |{1:>>}WW{6:  3 }c                                            |
  |*{2:    }{6:  4 }^                                             |
  …
Actual:
  |{1:>>}XX{6:  1 }a                                            |
  |XX{1:>>}{6:  2 }b                                            |
  |{1:>>}WW{6:  3 }c                                            |
  |*{2:    }{6:  ^4 }                                             |

blueyed added a commit to neomake/neomake that referenced this pull request Mar 28, 2019
This is meant to be more robust in case signs are not two chars long.
(neovim/neovim#9788)
blueyed added a commit to neomake/neomake that referenced this pull request Mar 28, 2019
This is meant to be more robust in case signs are not two chars long.
(neovim/neovim#9788)
@blueyed
Copy link
Contributor Author

blueyed commented May 22, 2019

Closing for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants