Highlight unicode characters in constants #163

Merged
merged 1 commit into from Jul 21, 2013

Conversation

Projects
None yet
2 participants
Contributor

amarshall commented Jul 14, 2013

#138 forgot about constants, and this remedies that mistake. Ruby doesn’t allow unicode characters as the first character of a constant (as shown by the below script), so we only highlight constants which have unicode characters as their second or later letter. I separately validated that all valid unicode characters are allowed (with a trivial modification of this script).

unicode_codepoints = 0x80..0x10FFFF

valid_codepoints = unicode_codepoints.select do |codepoint|
  str = [codepoint].pack 'U'
  begin
    eval "class #{str}; end"
  rescue SyntaxError
    false
  else
    true
  end
end

valid_codepoints  #=> []
Highlight unicode characters in constants
Except those which are the first letter (e.g. `Ír`), as Ruby does not
recognize them as valid constants. (See also #138)

@dkearns dkearns merged commit ab7c7e4 into vim-ruby:master Jul 21, 2013

@amarshall amarshall deleted the amarshall:unicode-constants branch Jul 21, 2013

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