-
Notifications
You must be signed in to change notification settings - Fork 450
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updated prettydiff.coffee to support EOL Detection #1461
Conversation
@@ -117,6 +117,7 @@ module.exports = class PrettyDiff extends Beautifier | |||
source: text | |||
lang: lang | |||
mode: "beautify" | |||
crlf: getDefaultLineEnding() # solved issue 1457 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The commit should reference the issue, not the code.
- Remove comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I see now another commit also incorrect did this:
options.eol = getDefaultLineEnding() ? options.eol #fixes issue #707 |
# configuration, or `null` if the Atom line ending configuration was not | ||
# recognized. | ||
# see: https://github.com/atom/line-ending-selector/blob/master/lib/main.js | ||
getDefaultLineEnding= -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Can you move this into
beautifier.coffee
along withatom-beautify/src/beautifiers/js-beautify.coffee
Lines 62 to 80 in c3e554d
# Retrieves the default line ending based upon the Atom configuration # `line-ending-selector.defaultLineEnding`. If the Atom configuration # indicates "OS Default", the `process.platform` is queried, returning # CRLF for Windows systems and LF for all other systems. # Code modified from atom/line-ending-selector # returns: The correct line-ending character sequence based upon the Atom # configuration, or `null` if the Atom line ending configuration was not # recognized. # see: https://github.com/atom/line-ending-selector/blob/master/lib/main.js getDefaultLineEnding= -> switch atom.config.get('line-ending-selector.defaultLineEnding') when 'LF' return '\n' when 'CRLF' return '\r\n' when 'OS Default' return if process.platform is 'win32' then '\r\n' else '\n' else return null
Since they are used in multiple places it should be centralized within thebeautifier
class.
@@ -117,6 +117,7 @@ module.exports = class PrettyDiff extends Beautifier | |||
source: text | |||
lang: lang | |||
mode: "beautify" | |||
crlf: getDefaultLineEnding() # solved issue 1457 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@prettydiff can you confirm the option is named crlf
? That seems strange to me, instead of eol
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that is the correct option name and yes eol
is a more intelligent name. http://prettydiff.com/documentation.xhtml#crlf
@@ -117,6 +117,7 @@ module.exports = class PrettyDiff extends Beautifier | |||
source: text | |||
lang: lang | |||
mode: "beautify" | |||
crlf: getDefaultLineEnding() # solved issue 1457 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Support custom
eol
fromoptions
. Seeoptions.eol = getDefaultLineEnding() ? options.eol #fixes issue #707
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- Update options documentation to reflect the
eol
option support in Pretty Diff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- You will need to add
eol
option to the languages which should support this option, such as https://github.com/Glavin001/atom-beautify/blob/master/src/languages/javascript.coffee#L33
Okay, I will try to finish this within tomorrow if possible. (Today, I have to clear out my work first) Check list
I think I will have to create things like dictionary as well to support alias option name and value. For example, Create config.json which contains alias data for specific option and make function to convert passing args base on this file. Ex. Map I will submit a pull request first once I finish and then we will discuss about this later. |
I do not follow what you mean. I do not want you to accidentally do unneeded work so I wanted to make sure you know Atom-Beautify supports different types of options:
I expect you to have something like I hope that helps! |
What does this implement/fix? Explain your changes.
As stated in Issue 1457, Pretty Diff required "crlf" parameter to set EOL type.
Does this close any currently open issues?
Issue 1457
Previously,this error had been reported by affanshahid in Issue 1009
Any other comments?
This error used the same logic in Issue 707 with some minor changes.