Skip to content

Potential Windows bug for user settings? #342

Open
@Nick-Mazuk

Description

@Nick-Mazuk

When looking through the user settings source code, I noticed that the get_parameters_from_file uses calc_preferences_filepath directly:

function configuration.get_user_settings(script_name, parameter_list, create_automatically)
if create_automatically == nil then create_automatically = true end
local exists = get_parameters_from_file(calc_preferences_filepath(script_name), parameter_list)

Yet calc_preferences_filepath returns a tuple:

local calc_preferences_filepath = function(script_name)
local str = finale.FCString()
str:SetUserOptionsPath()
local folder_name = str.LuaString
if not finenv.IsRGPLua and finenv.UI():IsOnMac() then
-- works around bug in SetUserOptionsPath() in JW Lua
folder_name = os.getenv("HOME") .. folder_name:sub(2) -- strip '~' and replace with actual folder
end
if finenv.UI():IsOnWindows() then
folder_name = folder_name .. path_delimiter .. "FinaleLua"
end
local file_path = folder_name .. path_delimiter
if finenv.UI():IsOnMac() then
file_path = file_path .. "com.finalelua."
end
file_path = file_path .. script_name .. ".settings.txt"
return file_path, folder_name
end

This seems to be working fine on macOS, but it seems like a strong code smell. Is this working on Windows?

Either way, I'd suggest rewriting it to destructure the tuple first, then only use the first value. While this seems to be acceptable Lua code, this would not be acceptable code in many other languages and could confuse many other people (including me at first).

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions