atom / language-javascript

JavaScript language package for Atom
Other
194 stars 237 forks source link

Dollar should be part of identifiers #374

Open PhiLhoSoft opened 8 years ago

PhiLhoSoft commented 8 years ago

Atom 1.7.3, Windows 7, although the latter is probably not relevant...

I searched for "dollar" and found no relevant issue, which is surprising... Actually, I am not sure if my issue should be here or in atom/atom (started to write there, made my mind to post here).

AFAIK, $ is part of the valid characters in identifiers, like underscore. Yet it is treated as a foreign punctuation character in many features of Atom. Examples:

And probably more...

Really annoying, particularly when you code in AngularJS... (many Angular identifiers start with $).

Side note: same problem in Java, except they add insult to injury by highlighting differently the part of the identifier after $... Will open a separate issue, of course.

50Wliu commented 8 years ago

This is a duplicate of #344 - feel free to subscribe there for updates.

PhiLhoSoft commented 8 years ago

I don't perceive this issue (which seems very narrow) to be a duplicate. My report isn't about syntax highlighting (or not only), but also about selection behavior and similar things. Now, if you fix all issues at once, that's fine then.

50Wliu commented 8 years ago

My apologies - I didn't read the issue closely enough :disappointed_relieved:.

Alhadis commented 8 years ago

@PhiLhoSoft Try removing $ from your editor's Non-word characters setting:

Figure-1
PhiLhoSoft commented 8 years ago

@Alhadis Ah, good idea, but then again, the big problem of this setting is that it is global to Atom, which makes it kind of useless. Lot of languages might not accept $ in the identifiers... And if I want to include - in CSS identifiers (where they are common), it might bring havoc in other source codes not putting spaces around this operator...

Alhadis commented 8 years ago

Then you scope the change to be language-specific. In your user config file:

".js.source":
  editor:
    nonWordCharacters: "/\\()\"':,.;<>~!@#%^&*|+=[]{}`?-…"
PhiLhoSoft commented 8 years ago

Wow, it works! Great solution, I forgot or didn't know about these language specific settings. http://flight-manual.atom.io/using-atom/sections/basic-customization/ For the record, at the end of config.cson, I added:

".js.source":
  editor:
    nonWordCharacters: "/\\()\"':,.;<>~!@#%^&*|+=[]{}`?-…"
".html.text":
  editor:
    nonWordCharacters: "/\\()\"':,.;<>~!@#%^&$*|+=[]{}`?…"
".stylus.source":
  editor:
    nonWordCharacters: "/\\()\"':,.;<>~!#%^&*|+=[]{}`?…"

And now I have a more consistent editing experience... :grin:

Alhadis commented 8 years ago

Don't you just love this program?!

PhiLhoSoft commented 8 years ago

I will leave this issue opened, as it is a (good) workaround, but it forces each user to do it (when they know the trick). Perhaps each language plugin should (be able to) set this setting by default.

And, but this is more an issue to open on core Atom, Find whole word doesn't take this setting in account. :disappointed: