mirror of
https://github.com/neovim/neovim.git
synced 2025-02-25 18:55:25 -06:00
Remove OOM checks: reverse_text()
This commit is contained in:
parent
21784aeb00
commit
e5e3cbf320
@ -345,32 +345,27 @@ void pum_redraw(void)
|
|||||||
*p = saved;
|
*p = saved;
|
||||||
|
|
||||||
if (curwin->w_p_rl) {
|
if (curwin->w_p_rl) {
|
||||||
char_u *rt = reverse_text(st);
|
char_u *rt = reverse_text(st);
|
||||||
|
char_u *rt_start = rt;
|
||||||
|
int size = vim_strsize(rt);
|
||||||
|
|
||||||
if (rt != NULL) {
|
if (size > pum_width) {
|
||||||
char_u *rt_start = rt;
|
do {
|
||||||
int size;
|
size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1;
|
||||||
|
mb_ptr_adv(rt);
|
||||||
|
} while (size > pum_width);
|
||||||
|
|
||||||
size = vim_strsize(rt);
|
if (size < pum_width) {
|
||||||
|
// Most left character requires 2-cells but only 1 cell
|
||||||
if (size > pum_width) {
|
// is available on screen. Put a '<' on the left of the
|
||||||
do {
|
// pum item
|
||||||
size -= has_mbyte ? (*mb_ptr2cells)(rt) : 1;
|
*(--rt) = '<';
|
||||||
mb_ptr_adv(rt);
|
size++;
|
||||||
} while (size > pum_width);
|
|
||||||
|
|
||||||
if (size < pum_width) {
|
|
||||||
// Most left character requires 2-cells but only 1 cell
|
|
||||||
// is available on screen. Put a '<' on the left of the
|
|
||||||
// pum item
|
|
||||||
*(--rt) = '<';
|
|
||||||
size++;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
screen_puts_len(rt, (int)STRLEN(rt), row, col - size + 1,
|
|
||||||
attr);
|
|
||||||
free(rt_start);
|
|
||||||
}
|
}
|
||||||
|
screen_puts_len(rt, (int)STRLEN(rt), row, col - size + 1,
|
||||||
|
attr);
|
||||||
|
free(rt_start);
|
||||||
free(st);
|
free(st);
|
||||||
|
|
||||||
col -= width;
|
col -= width;
|
||||||
|
@ -230,7 +230,9 @@ char_u *get_search_pat(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* Reverse text into allocated memory.
|
* Reverse text into allocated memory.
|
||||||
* Returns the allocated string, NULL when out of memory.
|
* Returns the allocated string.
|
||||||
|
*
|
||||||
|
* TODO(philix): move reverse_text() to strings.c
|
||||||
*/
|
*/
|
||||||
char_u *reverse_text(char_u *s)
|
char_u *reverse_text(char_u *s)
|
||||||
{
|
{
|
||||||
@ -1080,13 +1082,9 @@ proftime_T *tm; /* timeout limit or NULL */
|
|||||||
* it would be blanked out again very soon. Show it on the
|
* it would be blanked out again very soon. Show it on the
|
||||||
* left, but do reverse the text. */
|
* left, but do reverse the text. */
|
||||||
if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {
|
if (curwin->w_p_rl && *curwin->w_p_rlc == 's') {
|
||||||
char_u *r;
|
char_u *r = reverse_text(trunc != NULL ? trunc : msgbuf);
|
||||||
|
free(trunc);
|
||||||
r = reverse_text(trunc != NULL ? trunc : msgbuf);
|
trunc = r;
|
||||||
if (r != NULL) {
|
|
||||||
free(trunc);
|
|
||||||
trunc = r;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if (trunc != NULL) {
|
if (trunc != NULL) {
|
||||||
msg_outtrans(trunc);
|
msg_outtrans(trunc);
|
||||||
|
Loading…
Reference in New Issue
Block a user