Gracefully handle +ivy-tasks match errors
When trying to use +ivy-tasks in one of my projects it was failing w/ error: `(Stack overflow in regexp matcher)`. This was due to ripgrep searching a folder in the project root containing a minified bootstrap CSS source map file (which had a `TODO:` in it). Since that file was a single line of text concatenated together, the regex was getting passed ~540KB of text. To make it easier to recognize what is causing +ivy-tasks to fail I wrapped the failing code in `condition-case-unless-debug` and report the error and the file causing the error using `message!`. So now if there is a failure during the extraction of task from the search cmd's results it moves onto the next and alerts the user in separate pop-up. To avoid including the bootstrap file in the ripgrep search result, I added a `.ignore` file to the project that tells `rg` to ignore it. NOTE: I was surprised that this problem file was include in the ivy-tasks search because I expected the search to respect projectile ignore settings. Respecting projectile's ignored/unignored files and directories wouldn't be too difficult considering projectile provides a robust collection of functions to help support this. Also projectile's `projectile-ag` function is a great reference.
This commit is contained in:
parent
e1f7efdf1d
commit
e07972cffb
1 changed files with 11 additions and 5 deletions
|
@ -110,11 +110,17 @@ If WORKSPACE-ONLY-P (universal arg), limit to buffers in the current workspace."
|
||||||
(save-match-data
|
(save-match-data
|
||||||
(cl-loop with out = (shell-command-to-string cmd)
|
(cl-loop with out = (shell-command-to-string cmd)
|
||||||
for x in (and out (split-string out "\n" t))
|
for x in (and out (split-string out "\n" t))
|
||||||
when (string-match
|
when (condition-case-unless-debug ex
|
||||||
(concat "^\\([^:]+\\):\\([0-9]+\\):.+\\("
|
(string-match
|
||||||
(string-join task-tags "\\|")
|
(concat "^\\([^:]+\\):\\([0-9]+\\):.+\\("
|
||||||
"\\):?\\s-*\\(.+\\)")
|
(string-join task-tags "\\|")
|
||||||
x)
|
"\\):?\\s-*\\(.+\\)")
|
||||||
|
x)
|
||||||
|
(error
|
||||||
|
(message! (red "Error matching task in file: (%s) %s"
|
||||||
|
(error-message-string ex)
|
||||||
|
(car (split-string x ":"))))
|
||||||
|
nil))
|
||||||
collect `((type . ,(match-string 3 x))
|
collect `((type . ,(match-string 3 x))
|
||||||
(desc . ,(match-string 4 x))
|
(desc . ,(match-string 4 x))
|
||||||
(file . ,(match-string 1 x))
|
(file . ,(match-string 1 x))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue