samth
2022-6-15 15:14:37

that does not help


samth
2022-6-15 15:15:27

maybe @robby has some thoughts here. We’ve discovered that the problem with the quickscript-test/drracket.rkt test is that it ends up inserting the text into the interactions window instead of the definitions window, but it really seems like that shouldn’t happen.


robby
2022-6-15 15:25:24

I think you’ll need to explicitly change the focus to where you want it to be.


samth
2022-6-15 15:25:50

Right, the problem is that the tests do that, and adding even more doesn’t seem to fix it


robby
2022-6-15 15:26:03

The code I see at the link doesn’t do that.


samth
2022-6-15 15:26:51

The first failing test is this one: https://github.com/Metaxal/quickscript-test/blob/master/drracket.rkt#L103 and at line 96 there’s a call that I think sets the focus


samth
2022-6-15 15:27:51

and adding the focus call that @laurent.orseau suggested above at line 150, right before the other test failures, doesn’t fix those either


robby
2022-6-15 15:28:09

Can you point me to the run-script function?


robby
2022-6-15 15:28:27

oh, I found it


robby
2022-6-15 15:28:46

you’re ssaying that, with the code you sent me to (line 103), that you see typing in the interactions window first thing?


robby
2022-6-15 15:29:21

(during the string-insert script?)


samth
2022-6-15 15:30:23

In the cases where the test fails (it’s non-deterministic) the text “This is the editor” appears in the interactions window


robby
2022-6-15 15:33:11

IS that what the script does?


robby
2022-6-15 15:33:27

Do you know where the source code for the script is?


robby
2022-6-15 15:34:27

oh, duh. I found it now too. Sorry.



robby
2022-6-15 15:35:33

I don’t see anything obvious that’s wrong with that code. I’m not sure how ed gets calculated to pass to that function, tho.


samth
2022-6-15 15:36:06

Yeah I don’t know anything about how quickscript works, so I can’t speak to that


robby
2022-6-15 15:36:21

The use of the test suite library looks reasonable to me.


samth
2022-6-15 15:39:02

It’s calculated by the get-the-text-editor method in quickscript/tool which is: (define/private (get-the-text-editor) ; for a frame:text% : ;(define text (send frame get-editor)) ; for DrRacket: (define defed (get-definitions-text)) (if (send defed has-focus?) defed (get-interactions-text)))


samth
2022-6-15 15:39:36

Which seems to me like it should be doing the right thing here but I am very out of my depth


robby
2022-6-15 15:43:09

The call to the thunk on line 96 in drracket.rkt (the test suite) might happen concurrently with the call to run-script on 97 but if run-script is just taking us directly to the run-script private method in tool.rkt, then that’d explain why it doesn’t work.


samth
2022-6-15 15:46:32

Moving the content of that thunk (send (get-canvas) focus) outside of queue-callback causes the tests to pass consistently


robby
2022-6-15 15:47:49

That’s a sign that my analysis is right, I believe, but that’d be a bad change because you shouldn’t modify gui control state on a thread other than the eventspace main thread.


robby
2022-6-15 15:48:10

oh, I think I understand what’s going on.


robby
2022-6-15 15:48:26

The call to menu-select to run the script might be going before the call to on-focus.


robby
2022-6-15 15:48:48

the code needs to make sure that the on-focus call finishes before calling test:menu-select, I believe.


samth
2022-6-15 15:49:16

should the whole thing just be running inside queue-callback?


robby
2022-6-15 15:49:28

no


robby
2022-6-15 15:49:41

test:menu-select needs to run on a thread that’s not the eventspace main thrad


robby
2022-6-15 15:49:52

it is running on a thread that’s supposed to be “the user” who is clicking.


robby
2022-6-15 15:50:21

the idea is that you have two threads: one is the user who is doing stuff to the gui and those things are test:menu-select and friends


robby
2022-6-15 15:50:43

but then we sneak in some queue-callbacks because we want to tweak state more directly


robby
2022-6-15 15:51:12

and those need to be cooperating wth the test:menu-select (and friends) code, but just putting it in a queue’d callback is not enough to cooperate properly


samth
2022-6-15 15:51:27

but then it should be the “user” who sets the focus, right? but the thing it’s using to set the focus is something that has to be on the eventspace thread?


robby
2022-6-15 15:51:47

the user decides what to do, then does it.


robby
2022-6-15 15:51:54

that decision is happening on the non-eventspace main thread


robby
2022-6-15 15:52:02

then a callback should happen to actually take effect


robby
2022-6-15 15:52:09

imagine a button click. you move the mouse, that’s your thread


robby
2022-6-15 15:52:11

you click


robby
2022-6-15 15:52:25

then the OS comes in and puts something on the eventspace main thread in response to youclick.


robby
2022-6-15 15:52:27

your click


robby
2022-6-15 15:52:57

It might work to use test:run-one instead queue-callback to set the focus.


robby
2022-6-15 15:53:27

the issue is that the way that the test:* functions are movign stuff over to the eventspace main thread and the way queue-callback does are competing to see who goes first


robby
2022-6-15 15:53:46

queue-callback is a lower layer and the way it’s being used isn’t respecting the test: function’s invariants (in this case).


samth
2022-6-15 15:54:21

just changing queue-callback/res on that line to test:run-one does not fix it


robby
2022-6-15 15:54:39

what if you add some printfs to confirm that things are ahppening out of order?


robby
2022-6-15 15:54:51

(maybe using log-error is easiest)


samth
2022-6-15 15:55:01

if i add (sleep 5) right after the queue-callback it works


robby
2022-6-15 15:55:51

yeah, actually, now that I think about it, queue-callback/res should block until the thunk finishes


robby
2022-6-15 15:56:06

maybe the call to focus merely enqueues something that will change the foucs instead of changing the focus.


robby
2022-6-15 15:56:40

yep, that looks like it. From the docs:


samth
2022-6-15 15:56:41

that wouldn’t explain why doing it on the main thread causes it to work, would it?


robby
2022-6-15 15:56:42

“If the focus is in the window’s top-level window or if the window’s top-level window is visible and floating (i.e., created with the ’floatstyle), then the focus is immediately moved to this window. Otherwise, the focus is not immediately moved, but when the window’s top-level window gets the keyboard focus, the focus is delegated to this window.”


robby
2022-6-15 15:57:19

I think the simplest fix is to add a wait-until that checks that the definitions canvas has the focus


robby
2022-6-15 15:57:48

re “that wouldn’t …” doesn’t sound conclusive either way to me, actually.


samth
2022-6-15 16:00:05

ok that fixes it


samth
2022-6-15 16:00:10

I’ll open a PR


samth
2022-6-15 16:00:13

thanks everyone !


robby
2022-6-15 16:00:19

Thanks, Sam!


robby
2022-6-15 16:00:36

Note that we should probably audit other calls to focus too!


samth
2022-6-15 16:02:00

I’ll leave that to others :slightly_smiling_face:


samth
2022-6-15 16:02:05

PR opened


laurent.orseau
2022-6-15 19:58:18

Catching up from my phone. Woah, thanks for finding the fix both of you! I’ll merge the PR soon.


sschwarzer
2022-6-15 20:21:21

How can I add some horizontal whitespace between two strings in Scribble? I’m looking for roughly the equivalent of   in HTML or ~ in LaTeX.



sschwarzer
2022-6-15 20:29:46

Ok, then I even remembered correctly. :wink: However, it doesn’t work for me. I’ll experiment a bit and try to find out why it doesn’t work or what I need to change for it to work.


sschwarzer
2022-6-15 20:37:38

It always renders as a tilde. :confused: (This is with #lang scribble/manual if it matters.)

I can use @hspace[1] as a workaround though.


sorawee
2022-6-15 20:37:52

What’s your code?


sschwarzer
2022-6-15 20:39:45

For example a~b on it’s own paragraph (empty line before and after).


sorawee
2022-6-15 20:39:56

Well, you need @~


sorawee
2022-6-15 20:40:12

It’s an identifier exported from the library.


sorawee
2022-6-15 20:40:43

Actually, probably @\|~\|


sorawee
2022-6-15 20:41:10

So that ~b is not parsed as one token


sschwarzer
2022-6-15 20:47:03

> So that ~b is not parsed as one token Right, that’s the problem I ran into now.

I can use a@~ b, but that renders as a  b in the HTML (i.e. a regular space before the b).

a@\|~\|b works though.


philip.mcgrath
2022-6-15 22:09:19

Would pipelining support in db make sense?


philip.mcgrath
2022-6-15 22:11:33

According to https://www.postgresql.org/docs/current/libpq-pipeline-mode.html\|https://www.postgresql.org/docs/current/libpq-pipeline-mode.html, “While the pipeline API was introduced in PostgreSQL 14, it is a client-side feature which doesn’t require special server support and works on any server that supports the v3 extended query protocol.”


notjack
2022-6-16 00:46:18

I think a more significant improvement than any of this would be server-side support for http 2 and 3


notjack
2022-6-16 00:47:45

header compression, no head-of-line blocking, stream multiplexing, etc.


philip.mcgrath
2022-6-16 01:04:55

In the real world, I definitely agree! I think the big design question for http 3 is do we roll our own implementation—the catch being the deep way that crypto is integrated into the protocol—or use something like Quiche? https://github.com/cloudflare/quiche Or, wait for QUIC support in OpenSSL? https://github.com/quictls/openssl/discussions/54


samth
2022-6-16 01:05:32

There’s already part of an implementation by @ryanc


ryanc
2022-6-16 05:05:46

re pipelining: I think that implementing pipelining in a way that would be legal for the benchmark above would be a bad fit for the db library. (The benchmark imposes restrictions about the placement of Sync messages.) Specifically, I dislike the idea of either exposing Sync to the user or sending more messages after a Sync without seeing the results so far. Low-level pipelining support would also conflict a bit with the db library’s automatic query preparation. At a higher-level, though, it would be possible to build a batch query operation that eliminates some round-trip latencies. I haven’t done it yet because it only benefits PostgreSQL.