swiftcode icon indicating copy to clipboard operation
swiftcode copied to clipboard

In some sources '%' and '^' symbols are broken

Open scriptin opened this issue 10 years ago • 2 comments

Sometimes I can't input % an ^ characters, they show up as incorrect input when I type them in. I noticed that as I was typing some Clojure source and then some Erlang source.

This is a piece of source from Ring (Clojure), in which I have this bug (in the 1st line, on ^ symbol):

(defn- ^SimpleDateFormat formatter [format]
  (doto (SimpleDateFormat. ^String (http-date-formats format) Locale/US)
    (.setTimeZone (TimeZone/getTimeZone "GMT"))))

(defn- attempt-parse [date format]
  (try
    (.parse (formatter format) date)
    (catch ParseException _ nil)
    ;; Also catch RuntimeExceptions, needed for Clojure 1.3.0
    ;; See: https://groups.google.com/forum/#!topic/clojure/I5l1YHVMgkI
    (catch RuntimeException _ nil)))

(defn- trim-quotes [s]
  (str/replace s #"^'|'$" ""))

Another source pieces containing these characters work fine.

I use a Russian windows keyboard, but its' English layout seems to be the same as on normal US keyboards. Currently I'm using Google Chrome 31.0.1650.63 m on Windows 7.

scriptin avatar Dec 18 '13 13:12 scriptin

Hi! Thanks for the bug report. I'll try to recreate this later today, and see if I can find a fix for it.

voithos avatar Dec 18 '13 21:12 voithos

Seems like this is due to the ^ character being a "type hint". Unfortunately, highlight.js classifies this as a comment currently, so it's being stripped out of the typeable code.

I'll try to see if this can be fixed in highlight.js.

voithos avatar Dec 21 '13 02:12 voithos