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

Display most recently used tokens when completing #40

Closed
lppedd opened this issue Nov 13, 2020 · 8 comments
Closed

Display most recently used tokens when completing #40

lppedd opened this issue Nov 13, 2020 · 8 comments
Assignees
Labels
enhancement New feature or request

Comments

@lppedd
Copy link
Owner

lppedd commented Nov 13, 2020

As of now we display scopes which are strictly attached to a type.
Until we implement an independent extension which looks at the full VCS history, we can show the most recently used scopes without considering the inputted type. Obviously this mechanism is not precise, but it's still something worth adding.

It is important to highlight those items come from the (renamed) DefaultVcsCommitTokenProvider so we could display "Recently used" on the right.

A quick implementation shows this result:

image

Idea from #35
@Gerrit-K what do you think?

@lppedd lppedd added the enhancement New feature or request label Nov 13, 2020
@lppedd lppedd self-assigned this Nov 13, 2020
@lppedd lppedd added this to the 0.17.0 milestone Nov 13, 2020
@Gerrit-K
Copy link

@lppedd look awesome, thanks for picking this up!

@lppedd
Copy link
Owner Author

lppedd commented Nov 13, 2020

@Gerrit-K No problem 😄
I'm not a native speaker, is "Recently used" appropriate or should I go for something else?

Also, beware I can't guarantee the correctness of ordering, and with that I mean even if example-one has been used before my-scope-example, the order might be inverted (platform behavior).

@lppedd lppedd changed the title Display most recently used scopes when completing Display most recently used tokens when completing Nov 13, 2020
@lppedd
Copy link
Owner Author

lppedd commented Nov 13, 2020

Testing the integration with VCS was somewhat successfull. The code would feel like an hack to a possible contributor so it needs to be rewritting using the right objects (the flow of the VCS log is horrible to debug).

private fun getVcsCommits(): List<VcsCommitMetadata> {
  val vcsLogManager = VcsProjectLog.getInstance(project).logManager!!
  val vcsLogData = vcsLogManager.dataManager.also {
    it.addDataPackChangeListener(MyDataPackChangeListener(it))
    it.refresh(it.roots)
  }

  queue.take()

  val vcsScopesWithTimes = mutableListOf<VcsCommitMetadata>()
  val allCommits = vcsLogData.dataPack.permanentGraph.allCommits

  vcsLogData.miniDetailsGetter.loadCommitsData(
    allCommits.map { it.id },
    vcsScopesWithTimes::add,
    ProgressManager.getInstance().progressIndicator,
  )

  return vcsScopesWithTimes
}

inner class MyDataPackChangeListener(private val vcsLogData: VcsLogData) : DataPackChangeListener {
  override fun onDataPackChange(newDataPack: DataPack) {
    vcsLogData.removeDataPackChangeListener(this)
    queue.put(Unit)
  }
}

@Gerrit-K
Copy link

I'm not a native speaker, is "Recently used" appropriate or should I go for something else?

Me neither ;) but it sounds fine to me.

Also, beware I can't guarantee the correctness of ordering

That's a pity, but not a dealbreaker. Having suggestions in incorrect order is still better than having none at all I guess :)

Regarding your code, I'd love to help, but that would require me to learn kotlin from scratch as well as the IntelliJ plugin framework :/ Perhaps there's another open-source plugin out there that already parses the vcs log, from which you could take some bits?

@lppedd
Copy link
Owner Author

lppedd commented Nov 14, 2020

@Gerrit-K oh don't worry, I post code in issues only as a sort of "backup" or remainder.

@lppedd
Copy link
Owner Author

lppedd commented Nov 15, 2020

Implemented with commit a61f2b9.
Now there are two providers, one for recently used tokens (max 3 elements), and one for VCS-tokens (max 8 elements).

@lppedd lppedd closed this as completed Nov 15, 2020
@Gerrit-K
Copy link

@lppedd I received the plugin update today and tested it briefly. Works great and I think this will be really helpful for our workflow in the future. Thanks again for addressing this so quickly! :)

@lppedd
Copy link
Owner Author

lppedd commented Nov 24, 2020

@Gerrit-K fantastic! Let me know of any issue in case.

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

No branches or pull requests

2 participants