Skip to content

Conversation

@IanButterworth
Copy link
Member

completions = filter!(x -> isdir(s[1:prevind(s, first(cmp2)-i1+1)]*x), completions)
completions = filter!(completions) do x
try
isdir(s[1:prevind(s, first(cmp2)-i1+1)]*x)
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't this function return true or false? Does it always do that now or is the fall through returning nothing which would error in filter!?

Copy link
Member Author

Choose a reason for hiding this comment

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

It throws if it doesn't have perms to stat the path

Copy link
Member

Choose a reason for hiding this comment

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

Yes, and it should return false in that case, but right now it isn't I think?

Copy link
Member Author

Choose a reason for hiding this comment

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

@vtjnash perhaps you have an opinion on what to do here?

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Yes, the catch needs to end with a bool so that the filter doesn't error

@IanButterworth
Copy link
Member Author

Oh right, I thought @KristofferC was talking about changing the behavior of isdir not the filter anonymous function.

Copy link
Member

@vtjnash vtjnash left a comment

Choose a reason for hiding this comment

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

Though really I think we should later add a kwarg to these functions because this pattern is getting really annoying

Eg isdir(path, default=false)
Or default=nothing or default=throw (the current behavior) or default=Returns, or such

@KristofferC KristofferC merged commit 299b770 into JuliaLang:master Apr 30, 2024
@IanButterworth IanButterworth deleted the ib/replcomplete_isdir_guard branch April 30, 2024 11:31
KristofferC pushed a commit that referenced this pull request May 14, 2024
IanButterworth added a commit that referenced this pull request Jul 13, 2024
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.

REPL Pkg mode add <space> causes error on 1.11-beta1 and nightly.

3 participants