5 ms·
That’s my guess. Hard to do it any other way for Markdown. However, it could probably do that on a background thread and still be responsive with large amounts
by KerrAvon 4y ago
That’s my guess. Hard to do it any other way for Markdown. However, it could probably do that on a background thread and still be responsive with large amounts of text.
- ComputerGuru 4y agoForget background threads. People don’t know basic programming principles. The thought of debouncing user input didn’t even occur to them.
- foobiekr 4y agoThis. Incredible. Debouncing was done in the early 70s and even someone on;y familiar with more modern similar ideas would note that Nagling was invented in 1984 at the latest...
- stingraycharles 4y agoNot a UI / frontend developer. Doesn’t denouncing user input increase the latency before changes are rendered onto the screen? I would expect the changes to be visible ideally in the next frame, but I guess that’s not really an option?
- wtallis 4y agoDebouncing only has to carry a latency penalty for certain kinds of responses. A good UI should be able to start processing an action as soon as the button goes down, and add/amend the actions later once it's clear whether it was a press and hold, press and release, or double-click. If the appropriate responses to those three options are mutually exclusive to the point that the UI can't respond at all until the user input is fully disambiguated, then the keybindings are probably ill-considered and those unrelated or conflicting functions should not be sharing a button.
- ComputerGuru 4y agoIn the strictest sense, yes. But here clearly rendering is taking longer than 1/60s so it wouldn’t matter. The compromise would be to always start rendering immediately rather than wait x ms, but if you detect that the previous rendering hasn’t completed when the next input has arrived then you can start debouncing before rendering until you catch up.
- rustybolt 4y agoWhat do you mean by 'debouncing' here? I only know it as ignoring keypresses of the same key/button that happen too fast after each other (because they are likely a mechanical or electrical glitch rather than the user actually meaning to press the button/key multiple times). If you mean that, I don't know how it relates to the comment/article since I never needed to do debouncing in a desktop context (only for embedded stuff with actual push button circuitry attached).
- edflsafoiewq 4y agoSame idea, debouncing replaces a sequence of "re-render Markdown" events (button pushes) with a single "re-render" event (button push). Googling "debouncing" will turn up a bunch of articles about it.
- kiawe_fire 4y agoThat same concept, but one step removed if you will. The classic example is a data table with a text field that filters/searches the results, pulled from a server. Let’s say you want the results to update “live” as the user types, without having to click a “search” button. So if the user types “bacon” then she sees all results that contain the word “bacon” in them. Problem is, if the act of sending the text field input to the server and waiting for the results is relatively slow and blocks the UI from updating, then each key press causes a delay between the search results updating on the screen, and the next letter showing up in the search field. 1. User types “b” and then the app sends “b” to the server, pauses, gets a response of all results with the letter “b”. 2. User types “a”, and the app sends “ba” to the server… pauses… gets results. She types a “c”, the app sends “bac”, etc. Debouncing, then, means the app waits a short period of time to make sure the user is finished typing before sending the search term. Usually this means every time the user enters a letter into the search field, the app sets a timer for, say, 500ms. If the user doesn’t enter another letter for 500ms, great - send the search term, wait for the results. If the user does enter another letter within 500ms, then she must still be typing, so reset the timer back to 500ms and hold off on sending the search term out to the server.
- torstenvl 4y agoSeems like Markdown could be rendered 1-3 lines at a time, depending on line-height. It isn't like other formats where formatting information is spread all over the place.
- eyelidlessness 4y agoType two backticks, everything below is fine. Type one more… the entire rest of the syntax tree is potentially a new tree. Backspace, do the whole thing again.
- worthless-trash 4y agoBehavior solvable. When a user inserts to backticks, insert the closing backticks immediately.
- eyelidlessness 4y agoThat solves your problem but probably doesn’t solve the user’s.
- MauranKilom 4y agoCool, now explain how to do it for backspace. And now explain how anyone can ever turn existing text into a code block if every user action is "modified" to not turn existing text into a code block.
- worthless-trash 4y agoThis may be obvious but if you're trashing the second pair of backticks you obviously want the rest of it to be inside the backticks which required the first re-render so its not a mistake, the user made the request , follow through, render till the next set of bacticks into a block.. no trailing backticks ? Render everything.. thats the choice the user made. > And now explain how anyone can ever turn existing text into a code block if every user action is "modified" to not turn existing text into a code block. At no point did I mention that you couldnt wrap code in bacticks, I simply said the default insert would NOT have single pair backticks opening up to a forced re-render of every trailing element.
- WalterBright 4y agoThis can be done without multiple threads. MicroEmacs does it by checking the keyboard input buffer every once in a while while rendering. If there's a key in it, it abandons the rendering to go service the key. When there are no keys in the buffer, it tries rendering again. It works so well you never notice this is happening, you just get instance keyboard response.
- rayiner 4y agoAs I recall GNU Emacs does this too, by default. https://www.masteringemacs.org/article/improving-performance-emacs-display-engine https://www.masteringemacs.org/article/improving-performance...
- WalterBright 4y agoI expect this is normal practice.