Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Heredoc robustness suggestion #89

Closed
wdeshazer opened this issue May 10, 2024 · 3 comments
Closed

Heredoc robustness suggestion #89

wdeshazer opened this issue May 10, 2024 · 3 comments

Comments

@wdeshazer
Copy link

The Heredoc Regex isn't robust

tput -S <<!
> clear
> cup 10 10
> bold
> !

This heredoc was extracted from the tput man page. It fails to recognize the closing delimiter. I have looked through the shell.tmLanguage.json and believe that the following regex for the heredoc begin and end:

 "repository.heredoc.patterns[][email protected]": "(?:((?<!<)(?:<<-))(?:[ \\t]*+)(\"|')(?:[ \\t]*+)([^\"']+?)(?=\\s|;|&|<|\"|')((?:\\2))(.*))",
"repository.heredoc.patterns[][email protected]": "(?:(?:^\\t*)(?:\\3)(?=\\s|;|&|$))",

would be more robust with one that only sought the delimiter \\3. I preserved the further specificity of (?=\\s|;|&|$) although, I don't know if the heredoc strictly requires that per its specification. I'll look that up.

"repository.heredoc.patterns[][email protected]": "(?:((?<!<)(?:<<-))(?:[ \\t]*+)(\"|')(?:[ \\t]*+)([^\"']+?)(?=\\s|;|&|<|\"|')((?:\\2))(.*))",
"repository.heredoc.patterns[][email protected]": "(?:\\3)(?=\\s|;|&|$)"

I have a short term question and a long term question. Short term, what is the easiest way to get this in the my environment. Can I overwrite that path in my setting.json. Second, would you prefer to handle this or would you prefer a PR. I read through the documentation and the setup. I would have to work it within my priorities. But I could work this one and Issue #88 if you would like. I have not looked at that one yet, but I'll will soon and attempt to propose a solution rather than just throw an issue at you.

Regards,

Will

@wdeshazer
Copy link
Author

Closing the issue. I should have read the Heredoc specification before posting. The > are just prompts for illustrating command line entering of tput commands. I am still affected by #88 though.

@wdeshazer
Copy link
Author

Heredoc basic syntax

[COMMAND] <<[-] 'DELIMITER'
  HERE-DOCUMENT
DELIMITER

@jeff-hykin
Copy link
Owner

(?=\\s|;|&|$)

Stuff like this is purely/generally a hack to get things working in Textmate.

what is the easiest way to get this in the my environment

I thought the contributing.md covers it but I could be wrong so I'll give a TLDR. Fork/clone, install dependencies (ruby, and the textmate_grammar_builder (name might be slightly different) gem), edit the main.rb how you like, run commands/build, then open VS Code command pallet "Debug Extension", it'll open a new VS Code window, open shell code inside that new window, it'll use the new highlighter. Use VS Command pallet "TM Scopes" (or "TM tokens" or something of that nature) and move cursor over parts of the code to debug the labels given at each char.

attempt to propose a solution rather than just throw an issue at you.

Always appreciated. Even when I don't accept a PR, for example when someone edits the .tmLanguage.json directly even though its a generated file, it almost always saves me a good bit a time when actually fixing the problem. So PR's are always welcome.

I will say, Textmate sucks, so fixing simple things are often x10 harder than they should be. Theres a lot of up front cost to learning the quirks of the Textmate parser just to fix something simple.

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

No branches or pull requests

2 participants