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 ### Package Options
- `beautifyOnSave` - `beautifyOnSave` (Default *false*)
You can also choose to beautify on every file save. 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/), There is [Segment.io](https://segment.io/),
which forwards the data to [Google Analytics](http://www.google.com/analytics/), which forwards the data to [Google Analytics](http://www.google.com/analytics/),
to track what languages to track what languages

View File

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

View File

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