Mercurial > vim
diff src/channel.c @ 18104:e59ff7b5d7a7 v8.1.2047
patch 8.1.2047: cannot check the current state
Commit: https://github.com/vim/vim/commit/0e57dd859ecb1e8a3b91509d2f4343e839340eb8
Author: Bram Moolenaar <Bram@vim.org>
Date: Mon Sep 16 22:56:03 2019 +0200
patch 8.1.2047: cannot check the current state
Problem: Cannot check the current state.
Solution: Add the state() function.
author | Bram Moolenaar <Bram@vim.org> |
---|---|
date | Mon, 16 Sep 2019 23:00:04 +0200 |
parents | 0d9ec3a2821f |
children | 59bc3cd42cf5 |
line wrap: on
line diff
--- a/src/channel.c +++ b/src/channel.c @@ -3483,6 +3483,7 @@ channel_read(channel_T *channel, ch_part * Read from RAW or NL "channel"/"part". Blocks until there is something to * read or the timeout expires. * When "raw" is TRUE don't block waiting on a NL. + * Does not trigger timers or handle messages. * Returns what was read in allocated memory. * Returns NULL in case of error or timeout. */ @@ -3569,6 +3570,17 @@ channel_read_block( return msg; } +static int channel_blocking_wait = 0; + +/* + * Return TRUE if in a blocking wait that might trigger callbacks. + */ + int +channel_in_blocking_wait(void) +{ + return channel_blocking_wait > 0; +} + /* * Read one JSON message with ID "id" from "channel"/"part" and store the * result in "rettv". @@ -3592,6 +3604,7 @@ channel_read_json_block( int retval = FAIL; ch_log(channel, "Blocking read JSON for id %d", id); + ++channel_blocking_wait; if (id >= 0) channel_add_block_id(chanpart, id); @@ -3661,6 +3674,7 @@ channel_read_json_block( } if (id >= 0) channel_remove_block_id(chanpart, id); + --channel_blocking_wait; return retval; }