Skip to content

Commit

Permalink
Fix #24 - trap autosuggest matching regex errors to avoid polluting c…
Browse files Browse the repository at this point in the history
…onsole
  • Loading branch information
Alec Perkins committed Feb 23, 2012
1 parent 2a6175e commit 4ed8178
Show file tree
Hide file tree
Showing 6 changed files with 289 additions and 849 deletions.
32 changes: 18 additions & 14 deletions coffeetable-min.js

Large diffs are not rendered by default.

334 changes: 245 additions & 89 deletions coffeetable.js

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/Cakefile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ task 'build', 'compile coffee, minify js, build annotated source', ->
throw err if err
console.log stdout
console.log stderr
exec 'python ~/forks/pycco/pycco/main.py coffeetable.coffee', (err, stdout, stderr) ->
throw err if err
console.log stdout
console.log stderr
# exec 'python ~/forks/pycco/pycco/main.py coffeetable.coffee', (err, stdout, stderr) ->
# throw err if err
# console.log stdout
# console.log stderr
38 changes: 21 additions & 17 deletions src/coffeetable.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -210,24 +210,28 @@ buildAutosuggest = (text, e) ->
if token.length > 0
working_items.push([working_items[working_items.length-1][0][token], token])

# Set up the matching pattern to match the last token entered.
# Set up the matching pattern to match the last token entered. This
# process is wrapped in a try/catch to prevent faulty regex matches
# from polluting the console with (inconsequential) errors.
match_list = []
to_match = new RegExp('^' + tokens[tokens.length-1])

# Iterate over the properties of the latest working_item, running the
# matching pattern against the name of each one, building a list of
# the properties that match.
for attribute, value of working_items[working_items.length-1][0]
matches = to_match.exec(attribute)
if matches?.length > 0
# Push the name and type of property (for color coding)
match_list.push([attribute, typeof value])

# Sort the auto-suggest matches in ascending alphabetical order
match_list.sort()

# Display the list of matches
renderAutosuggest(working_items, match_list)
try
to_match = new RegExp('^' + tokens[tokens.length-1])

# Iterate over the properties of the latest working_item, running the
# matching pattern against the name of each one, building a list of
# the properties that match.
for attribute, value of working_items[working_items.length-1][0]
matches = to_match.exec(attribute)
if matches?.length > 0
# Push the name and type of property (for color coding)
match_list.push([attribute, typeof value])

# Sort the auto-suggest matches in ascending alphabetical order
match_list.sort()

# Display the list of matches
renderAutosuggest(working_items, match_list)
catch e


# ### renderAutosuggest
Expand Down
Loading

0 comments on commit 4ed8178

Please sign in to comment.