smartparens icon indicating copy to clipboard operation
smartparens copied to clipboard

Add a limit to how long we can take parsing the buffer

Open Fuco1 opened this issue 6 years ago • 5 comments

Let's put a two second cap on the parser so that emacs don't hang forever in a buffer with exceptionally large sexp.

Fuco1 avatar Jun 08 '18 11:06 Fuco1

The parser needs to run asynchronously instead of blocking the UI thread. A two second cap on the parser, if it is run asynchronously, sounds good to me.

Blocking the UI thread for this functionality, even for just 0.1 seconds, is not really acceptable.

gnzlbg avatar Jan 21 '19 15:01 gnzlbg

Elisp functions can not run asynchronously.

Fuco1 avatar Jan 21 '19 15:01 Fuco1

@Fuco1 I was thinking about running the computation in a different process asynchronously.

gnzlbg avatar Jan 21 '19 15:01 gnzlbg

I've tried that in the past on a couple projects and it is incredibly buggy, hard to debug and hard to write reliably. There is the async package but for anything more than a toy example it is a world of pain.

Much better way is to write something like a persistent server (a la LSP) which we can query with some API. I'm not planning on doing that either though, it's too much effort for not a lot of extra gain.

Users can opt-out of the highlights if the perf is bad. It is good in majority of cases and modes.

Fuco1 avatar Jan 21 '19 15:01 Fuco1

What about leveraging something like Tree-sitter1,2,3? I believe it can run both asynchronously and incrementally, and provide great understanding of a lot of various languages

andreyorst avatar Dec 05 '20 12:12 andreyorst