Patch 8.2.4830
Problem: Possible endless loop if there is unused typahead.
Solution: Only loop when the typeahead changed.
Files: src/channel.c
*** ../vim-8.2.4829/src/channel.c 2022-04-19 10:25:04.249373674 +0100
--- src/channel.c 2022-04-26 18:51:40.785227454 +0100
***************
*** 2029,2035 ****
/*
* Collapses the first and second buffer for "channel"/"part".
! * Returns FAIL if that is not possible.
* When "want_nl" is TRUE collapse more buffers until a NL is found.
* When the channel part mode is "lsp", collapse all the buffers as the http
* header and the JSON content can be present in multiple buffers.
--- 2029,2035 ----
/*
* Collapses the first and second buffer for "channel"/"part".
! * Returns FAIL if nothing was done.
* When "want_nl" is TRUE collapse more buffers until a NL is found.
* When the channel part mode is "lsp", collapse all the buffers as the http
* header and the JSON content can be present in multiple buffers.
***************
*** 2957,2962 ****
--- 2957,2973 ----
}
/*
+ * Return TRUE if for "channel" / "part" ch_json_head should be used.
+ */
+ static int
+ channel_use_json_head(channel_T *channel, ch_part_T part)
+ {
+ ch_mode_T ch_mode = channel->ch_part[part].ch_mode;
+
+ return ch_mode == MODE_JSON || ch_mode == MODE_JS || ch_mode == MODE_LSP;
+ }
+
+ /*
* Invoke a callback for "channel"/"part" if needed.
* This does not redraw but sets channel_need_redraw when redraw is needed.
* Return TRUE when a message was handled, there might be another one.
***************
*** 3002,3008 ****
buffer = NULL;
}
! if (ch_mode == MODE_JSON || ch_mode == MODE_JS || ch_mode == MODE_LSP)
{
listitem_T *item;
int argc = 0;
--- 3013,3019 ----
buffer = NULL;
}
! if (channel_use_json_head(channel, part))
{
listitem_T *item;
int argc = 0;
***************
*** 3248,3261 ****
}
/*
! * Return TRUE if "channel" has JSON or other typeahead.
*/
! static int
! channel_has_readahead(channel_T *channel, ch_part_T part)
{
! ch_mode_T ch_mode = channel->ch_part[part].ch_mode;
!
! if (ch_mode == MODE_JSON || ch_mode == MODE_JS || ch_mode == MODE_LSP)
{
jsonq_T *head = &channel->ch_part[part].ch_json_head;
--- 3259,3271 ----
}
/*
! * Return a pointer indicating the readahead. Can only be compared between
! * calls. Returns NULL if there is no readahead.
*/
! static void *
! channel_readahead_pointer(channel_T *channel, ch_part_T part)
{
! if (channel_use_json_head(channel, part))
{
jsonq_T *head = &channel->ch_part[part].ch_json_head;
***************
*** 3264,3272 ****
// process.
channel_parse_json(channel, part);
! return head->jq_next != NULL;
}
! return channel_peek(channel, part) != NULL;
}
/*
--- 3274,3291 ----
// process.
channel_parse_json(channel, part);
! return head->jq_next;
}
! return channel_peek(channel, part);
! }
!
! /*
! * Return TRUE if "channel" has JSON or other typeahead.
! */
! static int
! channel_has_readahead(channel_T *channel, ch_part_T part)
! {
! return channel_readahead_pointer(channel, part) != NULL;
}
/*
***************
*** 4013,4026 ****
if (!more)
{
// Handle any other messages in the queue. If done some more
// messages may have arrived.
if (channel_parse_messages())
continue;
// channel_parse_messages() may fill the queue with new data to
! // process.
! if (channel_has_readahead(channel, part))
continue;
// Wait for up to the timeout. If there was an incomplete message
--- 4032,4050 ----
if (!more)
{
+ void *prev_readahead_ptr = channel_readahead_pointer(channel, part);
+ void *readahead_ptr;
+
// Handle any other messages in the queue. If done some more
// messages may have arrived.
if (channel_parse_messages())
continue;
// channel_parse_messages() may fill the queue with new data to
! // process. Only loop when the readahead changed, otherwise we
! // would busy-loop.
! readahead_ptr = channel_readahead_pointer(channel, part);
! if (readahead_ptr != NULL && readahead_ptr != prev_readahead_ptr)
continue;
// Wait for up to the timeout. If there was an incomplete message
*** ../vim-8.2.4829/src/version.c 2022-04-26 12:51:01.078682252 +0100
--- src/version.c 2022-04-26 18:48:16.749347284 +0100
***************
*** 748,749 ****
--- 748,751 ----
{ /* Add new patch number below this line */
+ /**/
+ 4830,
/**/
--
hundred-and-one symptoms of being an internet addict:
61. Your best friends know your e-mail address, but neither your phone number
nor the address where you live.
/// Bram Moolenaar -- [email protected] -- http://www.Moolenaar.net \\\
/// \\\
\\\ sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///
--
--
You received this message from the "vim_dev" maillist.
Do not top-post! Type your reply below the text you are replying to.
For more information, visit http://www.vim.org/maillist.php
---
You received this message because you are subscribed to the Google Groups
"vim_dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vim_dev/20220426175351.AC6B51C04EA%40moolenaar.net.