remove do not change whitespace

This commit is contained in:
hxsf 2017-05-28 15:07:51 +08:00
parent c53b92e3fb
commit ce287977c8
4 changed files with 37 additions and 24 deletions

View File

@ -7633,7 +7633,7 @@ Maximum amount of characters per line (0 = disable) (Supported by Pretty Diff)
| `disabled` | :white_check_mark: | | `disabled` | :white_check_mark: |
| `default_beautifier` | :white_check_mark: | | `default_beautifier` | :white_check_mark: |
| `beautify_on_save` | :white_check_mark: | | `beautify_on_save` | :white_check_mark: |
| `do_not_change_whitespace` | :white_check_mark: | | `end_of_line` | :white_check_mark: |
**Description**: **Description**:
@ -7694,26 +7694,30 @@ Automatically beautify Lua files on save
2. Go into *Packages* and search for "*Atom Beautify*" package. 2. Go into *Packages* and search for "*Atom Beautify*" package.
3. Find the option "*Beautify On Save*" and change it to your desired configuration. 3. Find the option "*Beautify On Save*" and change it to your desired configuration.
##### [Do not change whitespace](#do-not-change-whitespace) ##### [End of line](#end-of-line)
**Namespace**: `lua` **Namespace**: `lua`
**Key**: `do_not_change_whitespace` **Key**: `end_of_line`
**Type**: `boolean` **Default**: `System Default`
**Type**: `string`
**Enum**: `CRLF` `LF` `System Default`
**Supported Beautifiers**: [`Lua beautifier`](#lua-beautifier) **Supported Beautifiers**: [`Lua beautifier`](#lua-beautifier)
**Description**: **Description**:
do not adjust whitespace (Supported by Lua beautifier) Override EOL from line-ending-selector (Supported by Lua beautifier)
**Example `.jsbeautifyrc` Configuration** **Example `.jsbeautifyrc` Configuration**
```json ```json
{ {
"lua": { "lua": {
"do_not_change_whitespace": false "end_of_line": "System Default"
} }
} }
``` ```
@ -16802,26 +16806,30 @@ undefined (Supported by Latex Beautify)
### Lua beautifier ### Lua beautifier
##### [Do not change whitespace](#do-not-change-whitespace) ##### [End of line](#end-of-line)
**Namespace**: `lua` **Namespace**: `lua`
**Key**: `do_not_change_whitespace` **Key**: `end_of_line`
**Type**: `boolean` **Default**: `System Default`
**Type**: `string`
**Enum**: `CRLF` `LF` `System Default`
**Supported Beautifiers**: [`Lua beautifier`](#lua-beautifier) **Supported Beautifiers**: [`Lua beautifier`](#lua-beautifier)
**Description**: **Description**:
do not adjust whitespace (Supported by Lua beautifier) Override EOL from line-ending-selector (Supported by Lua beautifier)
**Example `.jsbeautifyrc` Configuration** **Example `.jsbeautifyrc` Configuration**
```json ```json
{ {
"lua": { "lua": {
"do_not_change_whitespace": false "end_of_line": "System Default"
} }
} }
``` ```

View File

@ -27,7 +27,6 @@ DEFAULT_WARN_FN = (msg) ->
console.log('WARNING:', msg) console.log('WARNING:', msg)
module.exports = (str, indent, warn_fn, opts = {}) -> module.exports = (str, indent, warn_fn, opts = {}) ->
do_not_change_whitespace = !!opts?.do_not_change_whitespace
eol = opts?.eol or '\n' eol = opts?.eol or '\n'
indent = indent or DEFAULT_INDENT indent = indent or DEFAULT_INDENT
warn_fn = if typeof warn_fn == 'function' then warn_fn else DEFAULT_WARN_FN warn_fn = if typeof warn_fn == 'function' then warn_fn else DEFAULT_WARN_FN
@ -48,7 +47,7 @@ module.exports = (str, indent, warn_fn, opts = {}) ->
arr = line.split(/\]=*\]/, 2) arr = line.split(/\]=*\]/, 2)
comment = arr[0] comment = arr[0]
code = arr[1] code = arr[1]
line = comment + ']' + '='.repeat($template - 1) + ']' + if do_not_change_whitespace then code else adjust_space(code) line = comment + ']' + '='.repeat($template - 1) + ']' + adjust_space(code)
$template = 0 $template = 0
$template = 0 $template = 0
else else
@ -59,7 +58,7 @@ module.exports = (str, indent, warn_fn, opts = {}) ->
if !$template_flag if !$template_flag
line = line.trim() line = line.trim()
# remote all spaces on both ends # remote all spaces on both ends
line = if do_not_change_whitespace then line else adjust_space(line) line = adjust_space(line)
if !line.length if !line.length
return '' return ''
raw_line = line raw_line = line

View File

@ -20,8 +20,9 @@ module.exports = {
defaultBeautifier: "Lua beautifier" defaultBeautifier: "Lua beautifier"
options: options:
do_not_change_whitespace: end_of_line:
type: 'boolean' type: 'string'
default: false default: "System Default"
description: "do not adjust whitespace" enum: ["CRLF","LF","System Default"]
description: "Override EOL from line-ending-selector"
} }

View File

@ -4567,15 +4567,20 @@
"lua" "lua"
], ],
"properties": { "properties": {
"do_not_change_whitespace": { "end_of_line": {
"type": "boolean", "type": "string",
"default": false, "default": "System Default",
"description": "do not adjust whitespace (Supported by Lua beautifier)", "enum": [
"title": "Do not change whitespace", "CRLF",
"LF",
"System Default"
],
"description": "Override EOL from line-ending-selector (Supported by Lua beautifier)",
"title": "End of line",
"beautifiers": [ "beautifiers": [
"Lua beautifier" "Lua beautifier"
], ],
"key": "do_not_change_whitespace", "key": "end_of_line",
"language": { "language": {
"name": "Lua", "name": "Lua",
"namespace": "lua" "namespace": "lua"