{{ message }}

Merged
Merged

# enh(shell) recognize prompt that contain tilde(s) #2859

## Conversation

This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters

resolves #2858

### Changes

Add space (\s) and tilde (~) in the list of characters that a prompt can contain.

### Checklist

• Updated the changelog at CHANGES.md
• Added myself to AUTHORS.txt, under Contributors

reviewed
 begin: '^\\s{0,3}[/~\\s\\w\\d\$\$()@-]*[>%$#]', starts: { end: '$', subLanguage: 'bash' }

### joshgoebel Nov 13, 2020 • edited

I worry about false positives now though as this is getting very close to matching "almost anything" that has one of 4 characters in the middle... Feels like it's time to break this out into variants that handle come common prompt types...

Or else (at the very least) break this variant itself out and give it 0 relevance so it does not interfere with auto-detect of of other things.

Suggested change

### Mogztter Nov 15, 2020

Indeed this is what I was warning about - it's too broad now, probably now you realize this is why we didn't have this in the first place. :-) Spaces are tricky to include - it can now match too much.

I will remove \s from the regular expression and just keep ~.
I will also add a comment to explain why space is not included 😅

unless you want to start adding a few common variants - and we could see how far that gets us (or find out it's a terrible idea).

I think we should keep it simple. I would argue that using a single letter prompt (i.e. \$) is probably the way to go when you want to make sure that your input will be properly highlighted. If you are using a "complex" prompt then there's no guarantee.

requested changes

### joshgoebel commented Nov 15, 2020

 I think long-term the answer here might be the expand this and have a list of submodes and then try to match common things you'd have in a prompt (rather than matching the whole prompt): begin: /.../ //, very broad idea of what a prompt is (look-ahead) contains: [ PATH, HOSTNAME,  But probably pointless without a LARGE lists of real prompts to work with to see if we were getting some kind of reasonable hit rate. Here is mine for example: ~/w/highlight.js(master+41|✚1…24↩18) % 

reviewed
CHANGES.md Outdated Show resolved Hide resolved
changed the title recognize prompt that contain tilde(s) and/or space(s) recognize prompt that contain tilde(s) Nov 15, 2020
 enh(shell) recognize prompts that contain tilde(s) 
 bce2816 
resolves highlightjs#2858
approved these changes
changed the title recognize prompt that contain tilde(s) enh(shell) recognize prompt that contain tilde(s) Nov 15, 2020
merged commit 4fed71d into highlightjs:master Nov 15, 2020
11 checks passed