Consistent path expansion
parent
d8bda2d327
commit
bbbf38d474
|
@ -92,10 +92,20 @@ end
|
||||||
# FILE OPERATIONS #
|
# FILE OPERATIONS #
|
||||||
###################
|
###################
|
||||||
|
|
||||||
|
"""custom expand path function to ensure consistency"""
|
||||||
|
function editorExpandPath(filename::String)
|
||||||
|
if filename == ""
|
||||||
|
return ""
|
||||||
|
else
|
||||||
|
return abspath(expanduser(filename))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
""" Open a file and read the lines into the ed.rows array """
|
""" Open a file and read the lines into the ed.rows array """
|
||||||
function editorOpen(ed::Editor, filename::String)
|
function editorOpen(ed::Editor, filename::String)
|
||||||
try
|
try
|
||||||
filename = expanduser(filename)
|
filename = editorExpandPath(filename)
|
||||||
|
|
||||||
# If no file exists, create it
|
# If no file exists, create it
|
||||||
!isfile(filename) && open(filename, "w") do f end
|
!isfile(filename) && open(filename, "w") do f end
|
||||||
|
@ -126,7 +136,7 @@ function editorOpen(ed::Editor)
|
||||||
end
|
end
|
||||||
|
|
||||||
filename = editorPrompt(ed, "Open file: ")
|
filename = editorPrompt(ed, "Open file: ")
|
||||||
filename = expanduser(filename)
|
filename = editorExpandPath(filename)
|
||||||
|
|
||||||
if filename != ""
|
if filename != ""
|
||||||
editorOpen(ed, filename)
|
editorOpen(ed, filename)
|
||||||
|
@ -154,7 +164,7 @@ function editorSave(ed::Editor, path::String)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
ed.filename = expanduser(path)
|
ed.filename = editorExpandPath(path)
|
||||||
end
|
end
|
||||||
|
|
||||||
open(ed.filename, "w") do f
|
open(ed.filename, "w") do f
|
||||||
|
@ -276,7 +286,7 @@ function drawStatusBar(ed::Editor, buf::IOBuffer)
|
||||||
col += 1
|
col += 1
|
||||||
|
|
||||||
# filename
|
# filename
|
||||||
filename = configGet(:status_fullpath) ? abspath(expanduser(ed.filename)) : splitdir(ed.filename)[2]
|
filename = configGet(:status_fullpath) ? editorExpandPath(ed.filename) : splitdir(ed.filename)[2]
|
||||||
filestatus = string(filename, ed.dirty ? " *" : "")
|
filestatus = string(filename, ed.dirty ? " *" : "")
|
||||||
|
|
||||||
for i = 1:min(div(ed.width,2), length(filestatus))
|
for i = 1:min(div(ed.width,2), length(filestatus))
|
||||||
|
|
Loading…
Reference in New Issue