Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve default options and behaviour. #131

Open
wants to merge 15 commits into
base: master
Choose a base branch
from
Open

Conversation

CogentRedTester
Copy link
Owner

This PR is to do a wide update of file-browsers default options and behaviour
to make things more user friendly.

File-browser is several years old now, and in that time there are some legacy options
that can be improved, and some experimental features that now provide a superior
experience.

This removes the LuaJit requirements.

This is still rather experimental, so there may be bugs that appear when
parsing non-spec UTF16 strings (which Windows apparently supports in
filepaths!?).
To address this the parser is set to throw errors on any invalid input.
If an error is thrown the parser will abort and file-browser will
fallback to the default parser.
return true
end

---@param file string
---@return boolean
function fb_utils.valid_file(file)
if o.filter_dot_files and (string.sub(file, 1, 1) == ".") then return false end
if o.filter_dot_dirs == 'yes' or o.filter_dot_dirs == 'auto' and g.PLATFORM ~= 'windows' then
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if o.filter_dot_dirs == 'yes' or o.filter_dot_dirs == 'auto' and g.PLATFORM ~= 'windows' then
if o.filter_dot_files == 'yes' or o.filter_dot_files == 'auto' and g.PLATFORM ~= 'windows' then

Comment on lines +85 to +87
error(('malformed utf16le string at byte #%d (0x%04X) - high surrogate pair should be >= 0xdc00'):format(i+2, high_pair))
elseif low_pair < 0xdc00 then
error(('malformed utf16le string at byte #%d (0x%04X) - low surrogate pair should be < 0xdc00'):format(i+3, low_pair))
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
error(('malformed utf16le string at byte #%d (0x%04X) - high surrogate pair should be >= 0xdc00'):format(i+2, high_pair))
elseif low_pair < 0xdc00 then
error(('malformed utf16le string at byte #%d (0x%04X) - low surrogate pair should be < 0xdc00'):format(i+3, low_pair))
error(('malformed utf16le string at byte #%d (0x%04X) - high surrogate pair should be < 0xDC00'):format(i, high_pair))
elseif low_pair < 0xdc00 then
error(('malformed utf16le string at byte #%d (0x%04X) - low surrogate pair should be >= 0xDC00'):format(i+2, low_pair))

Comment on lines +73 to +74
local big = lshift(get_byte(), 8)
local codepoint = big + little
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
local big = lshift(get_byte(), 8)
local codepoint = big + little
local big = get_byte()
local codepoint = little + lshift(big, 8)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant