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

fix unicode completion in square brackets #25094

Closed
wants to merge 1 commit into from

Conversation

Jutho
Copy link
Contributor

@Jutho Jutho commented Dec 15, 2017

This fixes #24705, but I don't know anything of the REPL code so I am not sure this is the way to go.

To me, the name dict_identifier_key seems to indicate that it should only return non-trivial values identifier, partial_key, loc when the object in front of the square brackets is a Dict. Currently, only Array objects were special cased to return nothing, nothing, nothing, whereas all other objects returned true,nothing,nothing. I don't see the point of the true value, since this is then only used in completions where it means that for any object which is not a dict (or an array), followed by [, effectively all completions are disabled.

@@ -462,9 +462,9 @@ function dict_identifier_key(str,tag)
isa(obj, Array) && return (nothing, nothing, nothing)
end
begin_of_key = first(search(str, r"\S", nextind(str, end_of_identifier) + 1)) # 1 for [
begin_of_key==0 && return (true, nothing, nothing)
begin_of_key==0 && return (nothing, nothing, nothing)
Copy link
Contributor

Choose a reason for hiding this comment

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

Do the return statement on line 496, do anything with this change? This is also ok, as it gives the other types of completion a chance.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good question, probably not. But I have several questions regarding some of the code here, so I went with the minimal change. For example, it seems that line 462 (special casing Array objects) is no longer necessary. Probably processing the key (i.e. line 464) should be done after the check for being a dictionary on line 467, etc.

@Jutho
Copy link
Contributor Author

Jutho commented Jan 3, 2018

Bump; it would be great if this works in 0.7 and it's a small and, I believe, non-breaking change

@StefanKarpinski
Copy link
Member

The blocker here, I believe is review. Is anyone particularly familiar with this code?

@JeffBezanson
Copy link
Member

Is it possible to add a test case?

@Jutho
Copy link
Contributor Author

Jutho commented Jan 3, 2018

I am not sure how to test REPL code/behaviour. Should I just test the return values of these functions (i.e. dict_identifier_key and completions), as if I would test a normal function?

Also, I am pretty sure that the current patch is exactly, a mere patch, but not the best way to actually clean up this code. I implemented this to get the discussion going, but some input from anybody familiar with this code would still be very useful.

@Jutho Jutho closed this Aug 23, 2018
@Jutho Jutho deleted the jh/fixgetindexunicode branch August 23, 2018 08:06
@Jutho
Copy link
Contributor Author

Jutho commented Oct 31, 2018

I don't remember why I closed this, could this have been closed automatically because I somehow accidentally deleted this branch from my personal julia fork?

@Jutho Jutho restored the jh/fixgetindexunicode branch October 31, 2018 07:46
@Jutho Jutho reopened this Oct 31, 2018
@Jutho
Copy link
Contributor Author

Jutho commented Oct 31, 2018

Well, this probably needs an update, so I'll need to find some spare time.

@@ -462,9 +462,9 @@ function dict_identifier_key(str,tag)
isa(obj, Array) && return (nothing, nothing, nothing)
Copy link
Member

Choose a reason for hiding this comment

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

This should be AbstractArray, I think?

partial_key = str[begin_of_key:end]
(isa(obj, AbstractDict) && length(obj) < 1e6) || return (true, nothing, nothing)
(isa(obj, AbstractDict) && length(obj) < 1e6) || return (nothing, nothing, nothing)
Copy link
Member

Choose a reason for hiding this comment

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

Seems like this test should go before line 464

@stevengj
Copy link
Member

I have an updated version of this PR with tests, and will open a new PR shortly.

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.

Unicode entering mode within square brackets broken
5 participants