   prefix = lst[0]
   # slow, but should be fine with our small number of completions
   for word in lst
+    lower = word.toLowerCase()
     for c, idx in prefix
-      if (c isnt word[idx])
+      if (c.toLowerCase() isnt lower[idx])
         prefix = prefix.substr(0, idx)
         break
   prefix

    else if cmd is 'javap' or cmd is 'java' then ext is 'class'
    else true
  keepExt = -> return cmd isnt 'javap' and cmd isnt 'java'
  lastArg = _.last(args)
  potentialCompletions = []
  for i in [0...localStorage.length] by 1
    key = localStorage.key(i)
    continue unless key.substr(0, 6) is 'file::'
    fname = key.substr(6)
    continue unless validExtension(fname)
    if (fname.substr(0, lastArg.length) is lastArg)
      potentialCompletions.push(
        if not keepExt() then fname.split('.')[0]
        else fname

rs = null

# convenience functions for reading files from localStorage.
save_file = (fname, data) ->
  # inefficient but whatever
  lower = "file::#{fname.toLowerCase()}"
  for i in [0...localStorage.length] by 1
    key = localStorage.key(i)
    if key.toLowerCase() is lower
      localStorage.removeItem key
      break
  localStorage["file::#{fname}"] = data
load_file = (fname) -> localStorage["file::#{fname}"]
delete_file = (fname) -> localStorage.removeItem "file::#{fname}"

