-
-
Notifications
You must be signed in to change notification settings - Fork 372
Fixes lists with mixed indentation #485
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
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -6,7 +6,6 @@ var getIndent = require('./get-indentation') | |
|
|
||
| module.exports = indentation | ||
|
|
||
| var tab = '\t' | ||
| var lineFeed = '\n' | ||
| var space = ' ' | ||
| var exclamationMark = '!' | ||
|
|
@@ -21,7 +20,6 @@ function indentation(value, maximum) { | |
| var index | ||
| var indentation | ||
| var stops | ||
| var padding | ||
|
|
||
| values.unshift(repeat(space, maximum) + exclamationMark) | ||
|
|
||
|
|
@@ -56,18 +54,7 @@ function indentation(value, maximum) { | |
| index-- | ||
| } | ||
|
|
||
| if ( | ||
| trim(values[position]).length !== 0 && | ||
| minIndent && | ||
| index !== minIndent | ||
| ) { | ||
| padding = tab | ||
| } else { | ||
| padding = '' | ||
| } | ||
|
|
||
| values[position] = | ||
| padding + values[position].slice(index in stops ? stops[index] + 1 : 0) | ||
| values[position] = values[position].slice(stops[index] + 1) | ||
|
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not needed anymore because |
||
| } | ||
| } | ||
|
|
||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,34 @@ | ||
| # Mixed spaces and tabs | ||
|
|
||
| - (item 1.) Minimum list, equivalent to two spaces | ||
| - (item 2.) indented with 1 space, not enough indentation to be a subitem | ||
| - (item 2.1.) indented with tab | ||
|
|
||
|
|
||
| - (item 1.) Minimum list, equivalent to two spaces | ||
| - (item 1.1.) indentend with 2 spaces | ||
| - (item 1.2.) indented with tab | ||
|
|
||
|
|
||
| - (item 1.) List with 1 extra space | ||
| - (item 1.1.) indentend with 3 spaces | ||
| - (item 1.2.) indented with tab | ||
|
|
||
|
|
||
| - (item 1.) List with 2 extra space, equivalent to 1 tab indentation | ||
| - (item 1.1.) indentend with 4 spaces | ||
| - (item 1.2.) indented with tab | ||
|
|
||
|
|
||
| - (item 1.) List with 1 tab, equivalent to 4 spaces | ||
| - (item 1.1.) indentend with 4 spaces | ||
| - (item 1.2.) indented with tab | ||
|
|
||
|
|
||
| - (item 1.) list with double indentation and mixed items | ||
| - (item 1.1.) normal indentation with 1 tab | ||
| - (item 1.1.1.) item with 4 spaces + 4 spaces | ||
| - (item 1.1.2.) item with tab + 4 spaces | ||
| - (item 1.1.3.) item with 4 spaces + tab | ||
| - (item 1.1.4.) item with tab + tab | ||
| - (item 1.1.5.) item with 2 spaces + tab + 2 spaces (nasty!) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
For spaces (i.e. with
indent - lastIndent == 1), this is equivalent to juststops[indent]=index; lastIndent=indentFor tabs, this will create entries in
stopsfor all intermediate indents since the last one. For example, if the last indentation point is1(a space), and the next indentation point is5(a tab follows the initial space), this will add stops 2, 3, 4 and 5 pointing to character 1 (the tab).