Closes #105. Add options to mute errors.

New options:
- muteUnsupportedLanguageErrors
- muteAllErrors
This commit is contained in:
Glavin Wiechert 2014-09-28 16:22:29 -03:00
parent cd3656501c
commit 79fcdd9111
3 changed files with 32 additions and 11 deletions

View File

@ -85,10 +85,23 @@ For example:
### Package Options
- `beautifyOnSave`
- `beautifyOnSave` (Default *false*)
You can also choose to beautify on every file save.
- `analytics`
- `beautifyEntireFileOnSave` (Default *true*)
Beautification will normally only beautify your selected text.
However, when beautification occurs on save then it will
be forced to beautify the entire file's contents,
not just selected text.
- `muteUnsupportedLanguageErrors` (Default *false*)
Mute only *unsupported language* errors.
- `muteAllErrors` (Default *false*)
Do not show the *Atom Beautify Error Messages* panel
for any of the errors occurring while beautifying.
- `analytics` (Default *true*)
There is [Segment.io](https://segment.io/),
which forwards the data to [Google Analytics](http://www.google.com/analytics/),
to track what languages

View File

@ -136,8 +136,9 @@ beautify = ->
forceEntireFile = atom.config.get("atom-beautify.beautifyEntireFileOnSave")
# Show error
showError = (e) =>
# console.log(e)
@loadingView.hide()
if not atom.config.get("atom-beautify.muteAllErrors")
# console.log(e)
@messagePanel.attach()
@messagePanel.add(new PlainMessageView({
message: e.message,
@ -185,7 +186,9 @@ beautify = ->
# Asynchronously and callback-style
beautifyCompleted = (text) =>
# console.log 'beautifyCompleted'
if text instanceof Error
if not text?
# Do nothing, is undefined
else if text instanceof Error
showError(text)
else if oldText isnt text
# console.log "Replacing current editor's text with new text"
@ -313,6 +316,8 @@ plugin.configDefaults = _.merge(
analytics: true
beautifyOnSave: false
beautifyEntireFileOnSave: true
muteUnsupportedLanguageErrors: false
muteAllErrors: false
, defaultLanguageOptions)
plugin.activate = ->
handleSaveEvent()

View File

@ -252,6 +252,9 @@ module.exports =
category: version
#
if unsupportedGrammar
if atom.config.get("atom-beautify.muteUnsupportedLanguageErrors")
return beautifyCompleted(null)
else
throw new Error("Unsupported language for grammar '#{grammar}'.")
return