Skip to content

Commit

Permalink
Alignment sorting issue fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
franciscoamado committed Sep 28, 2018
1 parent 69b0a55 commit 24be941
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ You can validate if the Extension is enabled in `System Preferences >> Extension
## Known issues

* Simple text sorting
* Text needs to be aligned to work properly
* ~~Text needs to be aligned to work properly~~

## TODO

Expand All @@ -49,4 +49,4 @@ All the rest is free.

## Contributing

Open an [issue](https://github.com/FranciscoAmado/Sortify/issues/new) or a [Pull Request](https://github.com/FranciscoAmado/Sortify/compare). All help is appreciated.
Open an [issue](https://github.com/FranciscoAmado/Sortify/issues/new) or a [Pull Request](https://github.com/FranciscoAmado/Sortify/compare). All help is appreciated.
2 changes: 1 addition & 1 deletion Sortify/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
Expand Down
2 changes: 1 addition & 1 deletion SortifyExtension/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<key>CFBundlePackageType</key>
<string>XPC!</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<string>1.1</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
Expand Down
11 changes: 9 additions & 2 deletions SortifyExtension/SourceEditorCommand.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ class SourceEditorCommand: NSObject, XCSourceEditorCommand {
let sortedLines = lines
.subarray(with: linesRange)
.compactMap { $0 as? String }
.sorted(by: <)
.sorted { $0.trimmed < $1.trimmed }

invocation.buffer.lines.replaceObjects(in: linesRange, withObjectsFrom: sortedLines)
}

// Invoking the completion handler when done. Pass it nil on success, and an NSError on failure.
completionHandler(nil)
}

}

private extension String {

var trimmed: String {

return self.trimmingCharacters(in: .whitespacesAndNewlines)
}
}

0 comments on commit 24be941

Please sign in to comment.