mirror of
https://github.com/git-learning-game/oh-my-git.git
synced 2024-11-22 16:20:19 +01:00
Instead of sorting entries the file list, "very best sort" them :P
This commit is contained in:
parent
1a264e2beb
commit
764714b24e
1 changed files with 11 additions and 1 deletions
|
@ -14,7 +14,9 @@ func update():
|
||||||
var file_string = shell.run("find -type f")
|
var file_string = shell.run("find -type f")
|
||||||
var files = file_string.split("\n")
|
var files = file_string.split("\n")
|
||||||
files = Array(files)
|
files = Array(files)
|
||||||
files.sort()
|
# The last entry is an empty string, remove it.
|
||||||
|
files.pop_back()
|
||||||
|
files.sort_custom(self, "very_best_sort")
|
||||||
for file_path in files:
|
for file_path in files:
|
||||||
file_path = file_path.substr(2)
|
file_path = file_path.substr(2)
|
||||||
var child = $FileTree.create_item(root_item)
|
var child = $FileTree.create_item(root_item)
|
||||||
|
@ -28,3 +30,11 @@ func _on_item_selected():
|
||||||
|
|
||||||
shell.run("/tmp/fake-editor-noblock "+file_path)
|
shell.run("/tmp/fake-editor-noblock "+file_path)
|
||||||
|
|
||||||
|
func very_best_sort(a,b):
|
||||||
|
# We're looking at the third character because all entries have the form
|
||||||
|
# "./.git/bla".
|
||||||
|
if a.substr(2, 1) == "." and b.substr(2, 1) != ".":
|
||||||
|
return false
|
||||||
|
if a.substr(2, 1) != "." and b.substr(2, 1) == ".":
|
||||||
|
return true
|
||||||
|
return a.casecmp_to(b) == -1
|
||||||
|
|
Loading…
Reference in a new issue