Skip to content

Conversation

@ankitson
Copy link
Contributor

This seems to be a quick fix for #4390. Its my first PR to dotty so I might be missing something.

Copy link
Member

@dottybot dottybot left a comment

Choose a reason for hiding this comment

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

Hello, and thank you for opening this PR! 🎉

All contributors have signed the CLA, thank you! ❤️

Have an awesome day! ☀️

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

Can you add a test case to dotty.tools.repl.TabcompleteTests. Something like:

  @Test def sortedCompletions =
    fromInitialState { implicit state =>
      compiler
        .compile("class Foo { def comp3 = 3; def comp1 = 1; def comp2 = 2 }")
        .stateOrFail
    }
    .andThen { implicit state =>
      val expected = List("comp1", "comp2", "comp3")
      assertEquals(expected, tabComplete("(new Foo).comp").suggestions)
    }

}
interactiv.println(i"completion with pos = $pos, prefix = $prefix, termOnly = $termOnly, typeOnly = $typeOnly = ${completions.toList}%, %")
(completionPos, completions.toList)
(completionPos, completions.toList.sortBy(_.name.show))
Copy link
Contributor

Choose a reason for hiding this comment

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

You can use _.name.toString

@ankitson
Copy link
Contributor Author

Done!


@Test def sortedCompletions: Unit =
fromInitialState { implicit state =>
val src = """class Foo { def comp1 = 1; def compa = 3; def compA = 4 }"""
Copy link
Contributor

Choose a reason for hiding this comment

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

Use simple quotes. Triple quotes are not needed here.

Copy link
Contributor

Choose a reason for hiding this comment

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

I prefer the code snippet I gave you. I think the ordering is clearer:

class Foo { def comp3 = 3; def comp1 = 1; def comp2 = 2 }
val expected = List("comp1", "comp2", "comp3")

Copy link
Contributor

@allanrenucci allanrenucci left a comment

Choose a reason for hiding this comment

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

LGTM! Thanks @ankitson 🎉

}
interactiv.println(i"completion with pos = $pos, prefix = $prefix, termOnly = $termOnly, typeOnly = $typeOnly = ${completions.toList}%, %")
(completionPos, completions.toList)
(completionPos, completions.toList.sortBy(_.name.toString))
Copy link
Contributor

Choose a reason for hiding this comment

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

@smarter We have an ordering for Name that differs from the default String ordering. I am wondering if we should use it here? The Name ordering will not group type names and term names together

Copy link
Member

Choose a reason for hiding this comment

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

I think they should be grouped together, but we should also not display type completions if we're not in a type context

Copy link
Contributor

Choose a reason for hiding this comment

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

Sure but that's probably out of the scope of this PR

@scala scala deleted a comment from smarter May 1, 2018
@allanrenucci allanrenucci merged commit cdbb1be into scala:master May 1, 2018
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.

4 participants