Skip to content

Handle help look up on a non-existent class without crashing#270

Merged
davidgranstrom merged 2 commits into
davidgranstrom:mainfrom
salkin-mada:no-class-message
Jun 16, 2026
Merged

Handle help look up on a non-existent class without crashing#270
davidgranstrom merged 2 commits into
davidgranstrom:mainfrom
salkin-mada:no-class-message

Conversation

@salkin-mada

Copy link
Copy Markdown
Contributor

Requesting help for a subject (class) that has no help file currently throws a Lua error for classes. It not really a problem. But it doesn't look fantastic.

Chachachachaaanges:

  1. Guard the nil URI in render_help_file:
sclang.eval(cmd, function(input_path)
  if not input_path then
    utils.print(string.format('The class %s does not exist', subject))
    return
  end
  1. Unify styling: M.on_select previously used plain print(err) switched to utils.print(err) so the method "No results" message matches the new class message.

Both of these are routine "not found" outcomes, not errors, so routing them through utils.print (red ErrorMsg + persisted in :messages) may be heavier than warranted — it adds an entry to the message history on every miss. Would you/we prefer these informational misses go to the SuperCollider post window instead?(keeping nvim's message area / :messages uncluttered)

Ps. please note that this cannot really be tested without #269
If the doc-fix branch changes is not included the lua error explodes and we never see the new nice unified styling 8-)

Neeevertheless the important thing here is to catch the non-existing subject/class look up and prevent the lua crash.

@davidgranstrom

Copy link
Copy Markdown
Owner

Hi again,

Since #270 was just merged, would you mind rebasing this branch onto main?

Regarding utils.print, you can pass a custom hlgroup for a different highlight (e.g. WarningMsg or even StdoutMsg) to make it look more informative and not so much of an error. I think I rather keep the messages on the nvim side and not display them in the post window.

Handle help lookup for non-existent classes
@salkin-mada

salkin-mada commented Jun 16, 2026

Copy link
Copy Markdown
Contributor Author

Ajjj It became a merge.. not a rebase. Note to self: NEVER USE GÆTHØBZ GUI
(gonna remove the merge commit by forcing to origin, sorry — noisey)

@davidgranstrom

Copy link
Copy Markdown
Owner

No worries! Ping me when you are finished with the branch and I'll merge.

@salkin-mada

Copy link
Copy Markdown
Contributor Author

I chose 'WarningMsg' and forced to the last commit: fix(help): styling unification. I think this is good to go.

@salkin-mada

Copy link
Copy Markdown
Contributor Author

If you want we could go for MoreMsg to make it even more calm.

@davidgranstrom

Copy link
Copy Markdown
Owner

Thanks, looks good to me!

@davidgranstrom davidgranstrom merged commit 8767325 into davidgranstrom:main Jun 16, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants