florianwendelborn / atom-sorter Goto Github PK
View Code? Open in Web Editor NEW:signal_strength: :atom: package to sort things.
Home Page: https://atom.io/packages/sorter
License: MIT License
:signal_strength: :atom: package to sort things.
Home Page: https://atom.io/packages/sorter
License: MIT License
With the recent update for YAML, everything that isn't JSON is sorted as YAML which yields a garbage file.
The culprit is this try/catch
Seems like the solution is to detect if a file is actually YAML, this could easily be done by checking the current grammar of the file.
Note: Kind of a dupe of #4, however the title of that issue is more of feature description rather than symptom description.
No idea how to solve the current issues with YAML sorting being far too greedy. Probably gonna need another keyboard shortcut or something similar. ๐ข
This is just such an awesome plugin. Thank you for it. I use it regularly to sort keys in javascript objects:
{z:true, b:false} => {b:false, z:true}
But I was hoping to use it on html attributes as well, but it splits on the =
so it doesnt work. Is it possible to make it not split on =
?
Like:
zid="body" key="body"
Should sort to:
key="body" zid="body"
Also some time in my js objects I have a space between the colon so like this:
{z: true, b: false}
And this fails to sort, is it possible to ignore the first space after a colon?
Example of inline css:
position: absolute; top: 1; bottom: 3;
A regex split that would work for this is /\:\w*/
or for equals sign: /\=\w*/
[Enter steps to reproduce:]
Atom: 1.38.2 x64
Electron: 4.1.4
OS: linux 5.1.15-arch1-1-ARCH
Thrown From: sorter package 1.3.0
Uncaught TypeError: Cannot read property 'replace' of null
At /usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:1319
TypeError: Cannot read property 'replace' of null
at TextBuffer.setTextInRange (/usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:859:27)
at newRange.transact (/usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:846:49)
at TextBuffer.transact (/usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:1316:16)
at TextBuffer.setTextInRange (/usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:846:29)
at TextEditor.setTextInBufferRange (/usr/lib/atom/src/text-editor.js:1364:29)
at getRanges.forEach.range (/packages/sorter/source/index.js:54:10)
at Array.forEach (<anonymous>)
at sort (/packages/sorter/source/index.js:53:27)
at /packages/sorter/source/index.js:37:25)
at CommandRegistry.handleCommandEvent (/usr/lib/atom/src/command-registry.js:384:43)
at CommandRegistry.dispatch (/usr/lib/atom/src/command-registry.js:273:17)
at AtomEnvironment.dispatchContextMenuCommand (/usr/lib/atom/src/atom-environment.js:1383:19)
at EventEmitter.outerCallback (/usr/lib/atom/src/application-delegate.js:305:47)
at EventEmitter.emit (events.js:182:13)
-2:31.3.0 application:add-project-folder (ol.tree-view-root.full-menu.list-tree.has-collapsable-children.focusable-panel)
2x -2:12.4.0 editor:newline (input.hidden-input)
-2:10.1.0 core:paste (input.hidden-input)
-2:09.0 core:move-up (input.hidden-input)
-2:05.8.0 core:paste (input.hidden-input)
2x -1:55.4.0 sorter:sort (div.line)
-1:47.2.0 duplicate-removal:toggle (div.line)
-1:36.7.0 window:save-all (input.hidden-input)
-0:35.5.0 editor:newline (input.hidden-input)
-0:30.5.0 core:paste (input.hidden-input)
-0:29.8.0 editor:newline (input.hidden-input)
-0:28.3.0 core:paste (input.hidden-input)
-0:21.9.0 sorter:sort (div.line)
-0:19.9.0 duplicate-removal:toggle (div.line)
-0:15.1.0 window:save-all (input.hidden-input)
atom-beautify 0.33.4
atom-file-icons 0.7.1
duplicate-removal 0.1.3
scroll-color 0.3.0
sorter 1.3.0
In javascript lots of times we have default values for arguments, something like this:
function({ foo, bar, qux=8, baz=9 })
Some people put spaces between the ='s sign.
If I highlight within the curlies and try to sort it fails. :(
[Enter steps to reproduce:]
Atom: 1.42.0 x64
Electron: 4.2.12
OS: linux 5.4.12-arch1-1
Thrown From: sorter package 1.3.0
Uncaught TypeError: Cannot read property 'replace' of null
At /usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:1323
TypeError: Cannot read property 'replace' of null
at TextBuffer.setTextInRange (/usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:863:27)
at newRange.transact (/usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:850:49)
at TextBuffer.transact (/usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:1320:16)
at TextBuffer.setTextInRange (/usr/lib/atom/node_modules/text-buffer/lib/text-buffer.js:850:29)
at TextEditor.setTextInBufferRange (/usr/lib/atom/src/text-editor.js:1561:29)
at getRanges.forEach.range (/packages/sorter/source/index.js:54:10)
at Array.forEach (<anonymous>)
at sort (/packages/sorter/source/index.js:53:27)
at /packages/sorter/source/index.js:37:25)
at CommandRegistry.handleCommandEvent (/usr/lib/atom/src/command-registry.js:405:43)
at CommandRegistry.dispatch (/usr/lib/atom/src/command-registry.js:292:17)
at AtomEnvironment.dispatchContextMenuCommand (/usr/lib/atom/src/atom-environment.js:1583:19)
at EventEmitter.outerCallback (/usr/lib/atom/src/application-delegate.js:329:47)
at EventEmitter.emit (events.js:182:13)
-8:09.5.0 core:paste (input.hidden-input)
-5:17.2.0 core:copy (span.syntax--meta.syntax--paragraph.syntax--text)
2x -5:15.8.0 core:backspace (input.hidden-input)
-5:13.3.0 find-and-replace:show (input.hidden-input)
-5:11.6.0 core:paste (input.hidden-input)
3x -5:10.5.0 core:confirm (input.hidden-input)
-4:42.3.0 sorter:sort (div.line.cursor-line)
-4:40.6.0 duplicate-removal:toggle (div.line)
-4:32.1.0 window:save-all (input.hidden-input)
-2:01.4.0 editor:newline (input.hidden-input)
-2:00.1.0 core:paste (input.hidden-input)
2x -1:50.9.0 core:backspace (input.hidden-input)
-1:39.5.0 core:copy (span.syntax--meta.syntax--paragraph.syntax--text)
-0:46.4.0 sorter:sort (div.line)
-0:44.8.0 duplicate-removal:toggle (div.line)
-0:35.9.0 window:save-all (input.hidden-input)
atom-beautify 0.33.4
atom-file-icons 0.7.1
duplicate-removal 0.1.3
scroll-color 0.3.0
sorter 1.3.0
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.