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

RegExp in JS #51

Closed
faiwer opened this issue Jan 18, 2018 · 21 comments
Closed

RegExp in JS #51

faiwer opened this issue Jan 18, 2018 · 21 comments

Comments

@faiwer
Copy link

faiwer commented Jan 18, 2018

img_18_01_12 34 19_6b135bf6c6b

const matches = str.match(/^\s*(\{[^}]*\}|[\d.,+*()/\s-]+)\s*/);

A little problem at \s in ([]).

@borela
Copy link
Owner

borela commented Jan 18, 2018

Was this related to the it #50 problem? I could not reproduce with that code alone.

@faiwer
Copy link
Author

faiwer commented Jan 18, 2018

Hm. I created a new empty file with only this line:
img_18_01_16 07 18_ed6fb611ac1

const matches = str.match(/^\s*(\{[^}]*\}|[\d.,+*()/\s-]+)\s*/);

naomi ends the regExp at /, but this / in [] group :) v3.1.1.

@borela
Copy link
Owner

borela commented Jan 18, 2018

Which color scheme are you using?

@borela
Copy link
Owner

borela commented Jan 18, 2018

Ooo I am using sublime's core to highlight the regex, what version of sublime are you using?

@faiwer
Copy link
Author

faiwer commented Jan 18, 2018

  • ST: Sublime Text 3, Build 3152
  • OS: LinuxMint
  • Color schema: CustomHighlightMonokai JSON+ (SL)

I changed for test this color schema by default Monokai, but the problem is still here. Nothing changed. I tried some another schemes - nothing happens.

@borela
Copy link
Owner

borela commented Jan 18, 2018

It's probably the core, I am using the 3156 build, I'll use the fixed regex code directly from the core to fix the syntax in earlier builds too.

@borela
Copy link
Owner

borela commented Jan 18, 2018

Check this pull #52 I tested locally and it fixes the issue, had to rewrite the regex patterns to remove the dependency from the core.

@faiwer
Copy link
Author

faiwer commented Jan 18, 2018

img_18_01_23 29 52_ec4651d97d7
So, all right here ;) Thank you. Also I see different colours for different regexp regions. They weren't before.

@borela
Copy link
Owner

borela commented Jan 18, 2018

I am going to check the scopes before merging.

@borela
Copy link
Owner

borela commented Jan 18, 2018

It should be close to the colors the scopes the core was giving now. Can you check it before I merge?

@faiwer
Copy link
Author

faiwer commented Jan 18, 2018

naomi:
img_19_01_00 03 46_d0eee1d2044

default javascript package:
img_19_01_00 04 09_8166d87c94c

@borela
Copy link
Owner

borela commented Jan 18, 2018

Which color scheme are you using?
Please post that sample.

@faiwer
Copy link
Author

faiwer commented Jan 18, 2018

sample:

const matches = str.match(/^\s*(\{[^}]*\}|[\d.,+*()/\s-]+)\s*/);
const a = /(19|20)\d\d[- /.](0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])/;
const b = /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]?)$/

ColorScheme: Monokai (SL)

@borela
Copy link
Owner

borela commented Jan 18, 2018

The difference in the const keyword was that in older builds, it was being highlighted as keyword instead of storage.type, the newer builds(screen) are have this one corrected;

The variable name in naomi is scoped as entity.name.variable(green) while the core syntax is variable.other.readwrite (white), I did that to follow the guidelines and enable the indexer to work with variables, so I think the core is bugged on this one.

The lastest commits I sent to the pull request, made the regex literal similar to how the core is highlighting it(without the bug):

current

@borela
Copy link
Owner

borela commented Jan 18, 2018

@borela borela closed this as completed Jan 18, 2018
@faiwer
Copy link
Author

faiwer commented Jan 18, 2018

Error loading Packages/JavaScript/Regular Expressions (JavaScript).sublime-syntax: Unable to read Packages/JavaScript/Regular Expressions (JavaScript).sublime-syntax in Packages/Naomi/syntaxes/naomi.fjsx15.sublime-syntax

img_19_01_00 43 52_c052cb0eb7c

Something got wrong. I also tried to remove and install the package again.

@borela borela reopened this Jan 18, 2018
@borela
Copy link
Owner

borela commented Jan 18, 2018

I am going to try to reproduce the issue on my pc.

@borela
Copy link
Owner

borela commented Jan 18, 2018

Did try to install from package control or cloned the repo? If you clonned, are you on the master branch? After I merged the patch #52, it removed any references to Packages/JavaScript/Regular Expressions (JavaScript).sublime-syntax which was the core syntax.

@borela
Copy link
Owner

borela commented Jan 18, 2018

I think it's probably a cache issue, sublime compiles the syntaxes to a faster format and put it in a cache folder under:

  • OS X: ~/Library/Application Support/Sublime Text 3
  • Windows: %LOCALAPPDATA%\Sublime Text 3
  • Linux: ~/.config/sublime-text-3

You'll see a Naomi directory inside the cache directory; Close sublime, delete the Naomi under the cache directory and start it again.

@faiwer
Copy link
Author

faiwer commented Jan 19, 2018

Yeah, you're right. After removing the Cache directory and restarting sublime the problem dissolved.

@faiwer faiwer closed this as completed Jan 19, 2018
@borela
Copy link
Owner

borela commented Jan 19, 2018

Great that it solved; caching issues are pretty rare on sublime, if you know how to reproduce them reliably, post an issue on the core https://github.com/SublimeTextIssues/Core/issues

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants