to measure window height when resizing contents
Sometimes these values differ by a pixel,
we may never know why.
window.innerHeight seems to be larger when they disagree, causing an extra scrollbar to be drawn.
A problem can happen when two messages come in for different
comms, where the second depends on the first (for example, the
first might be a message setting the state of a widget, and the
second triggering a view creation for the widget). Since comm
message queues are independent of each other, the second message
could be executed before the first message.
This exposes a more fundamental assumption users are likely to
have that messages from python are processed synchronously.
Thanks to @dmadeka for reporting an error that led to discovering this issue.
The function in charge of actually converting cursor offset to
CodeMirror line number and character number was actually crashing when
the cursor was at the last character (loop until undefined, then access
length of variable, which is undefined).
This was hiding a bug in which when you would completer to a single
completion pressing tab after as-you-type filtering, the completion
would be completed twice.
The logic that was supposed to detect whether or not all completions had
a common prefix was actually faulty as the common prefix used to be a
string but was then changed to an object. Hence the logic to check
whether or not there was actually a common prefix was always true, even
for empty string, leading to the deletion of the line (replace by '') in
some cases.
Because the binary messages are now deserialized using the asynchronous FileReader API, we need to have some way to force the messages to still be processed in the order they are received. This patch implements a simple processing queue using promises.