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

Performance improvements and other fixes in code completion #3146

Merged
merged 8 commits into from
Nov 30, 2016

Conversation

kaloyan-raev
Copy link
Contributor

@kaloyan-raev kaloyan-raev commented Nov 22, 2016

What does this PR do?

This PR contains performance improvements for the code completion discussed in #2815.

Issue 1. Avoid overloading the DOM tree when creating the content assist widget.

Instead of adding a <li> element to the DOM tree for each proposal item, now there are no more than 50 elements added for displaying the available proposals. The scroll event is handled to update this fixed number of elements.

An "extra top row" and an "extra bottom row" are introduced to simulate a full list of items in the browser. These extra rows are empty and their height is adjusted as necessary to place the list's scrollbar in the correct scroll position and with the correct height. These extra rows are never visible to users.

An "id" attribute with the index number is added to the <li> elements. It is necessary for the key navigation from the currently selected element. As the selected element may go out the buffered range when scrolling, the index in the "id" attribute is used to determine the newly selected element on key navigation (up, down, pageup, pagedown).

Additional care is taken to keep the keyboard focus adequate. This is necessary because the currently focused <li> element may go out of range when scrolling, and the browser will move the focus to another element in the DOM tree, outside of the ContentAssistWidget.

Issue 2. respect the CompletionList.isIncomplete flag.

The latest completion result is stored in the LatestCompletionResult object. If the result is "complete", i.e. the isIncomplete flag is false, then the latest completion result is checked if it is still good for the current document position. In such case no new completion request is sent and the latest completion result is reused after filtering.

A completion request is always sent if the user hits Ctrl+Space, regardless if there is a good latest completion result for the same position.

Other fixes

  • Fixed flickering of the content assist widget between keystrokes
  • The content assist widget sometimes did not disappear when automatically applying the single completion result
  • Fixed retrieval of completion item's documentation when a Completion Resolve request is necessary

What issues does this PR fix or reference?

Fixes #2815: Performance issues with code completion

Previous behavior

The initial invocation of code completion took several seconds, especially when the the list of completion proposals is long. Subsequent key stroke may also cause noticeable UI freeze.

New behavior

Smoother experience with code completion. Faster initial response, no freeze on further typing.

Signed-off-by: Kaloyan Raev [email protected]

@codenvy-ci
Copy link

Can one of the admins verify this patch?

If the isIncomplete flag is false, i.e. the completion result is
complete, then additional typing for the same word should not trigger a
new completion request. The latest completion result should be reused.

Signed-off-by: Kaloyan Raev <[email protected]>
@kaloyan-raev kaloyan-raev changed the title Avoid overloading the DOM tree of the ContentAssistWidget Performance improvements in code completion Nov 24, 2016
@kaloyan-raev kaloyan-raev changed the title Performance improvements in code completion Performance improvements and other fixes in code completion Nov 29, 2016
@vparfonov vparfonov merged commit f1710e6 into eclipse-che:master Nov 30, 2016
@bmicklea bmicklea added this to the 5.0.0-M8 milestone Nov 30, 2016
@kaloyan-raev kaloyan-raev deleted the code-assist-widget branch November 30, 2016 19:47
JPinkney pushed a commit to JPinkney/che that referenced this pull request Aug 17, 2017
…che#3146)

* Avoid overloading the DOM tree of the ContentAssistWidget

Signed-off-by: Kaloyan Raev <[email protected]>

* Ensure the code assist widget is closed when applying proposal

Signed-off-by: Kaloyan Raev <[email protected]>

* Respect isIncomplete flag in the completion result

If the isIncomplete flag is false, i.e. the completion result is
complete, then additional typing for the same word should not trigger a
new completion request. The latest completion result should be reused.

Signed-off-by: Kaloyan Raev <[email protected]>

* Fix flickering between keystrokes during code completion

Signed-off-by: Kaloyan Raev <[email protected]>

* Fine tune the rules for making new completion request

Signed-off-by: Kaloyan Raev <[email protected]>

* Set the correct offset when applying code completion

* Force a completion request message on Ctrl+Space

Signed-off-by: Kaloyan Raev <[email protected]>

* Fixed retrieval of CompletionItem document via Resolve request

Signed-off-by: Kaloyan Raev <[email protected]>
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.

Performance issues with code completion
4 participants