Closed arn-all closed 4 years ago
More specifically :
That's a great improvement. :) However, few things I noticed:
const words = document.getText(range).split(RegExp('[\\t\\s]+'))
words[words.length - 1]
isn't very robust I think, because you can have trailung keywords and such. In a case like fix 1 all box/relax iso 0.0 vmax 0.001
, wouldn't that actually capture "fix 0.0001"? Your previous version was actually better in that regard, but maybe it needs more elaborate(e.g. iterative) selection rules. Maybe something based on this:
if (!docs?.command) {
const sub_com = snippet.split(RegExp('[\\t\\s]+'));
docs = get_documentation(sub_com[0])
}
Having that kind of check running over the possible combinations may be an idea, e.g: first check if get_documentation(sub_com[0] + ' ' + sub_com[3])
returns something, if it doesn't, check get_documentation(sub_com[0] + ' ' + sub_com[2])
, and so on...
I admit it's probably not very efficient but it may not really be a problem. I am not sure. Most of the time the first check would actually return something I guess. The other cases would take care of expressions with missing parameters. Capturing that may also provide a possibility to show error-squiggles later on. :thinking:
EDIT: Just seen you already fixed the words[words.length - 1]
:+1:
Yes, sorry for the typo !
Edit :
The hover now supports "fix foo bar box/relax" pattern