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

Remove unused live completion code #695

Closed
wants to merge 4 commits into from

Conversation

pamelafox
Copy link
Collaborator

High-level description of change

This was another change related to the webpack PR that can actually go straight into master.

ScratchpadAutosuggest includes two types of functionality:

  1. live completion of functions
  2. documentation popup

We disabled #1 in 4e028ca and we still use #2.

This PR removes the code associated with #1. The unused code is fairly entangled in other code, so removing it will make future modernization PRs cleaner. It's also very ace-dependent code, so it'd be likely to change if a Monaco upgrade ever happens, eg.

Have you added tests to cover this new/updated code?

I manually checked the demo to ensure documentation pop up still working. There are also 2 autosuggest related tests that still pass.

Risks involved

Hm. This PR removes the code for feature from Gigabyte-Giant to let users turn off autosuggest via a URL query parameter + keyboard shortcut. That was added back when live completion was still part of autosuggest, so I believe its primary purpose no longer exists. I also cannot get it to do anything on live KA. So it seems safe to remove, and if its not, the devs watching this repo might let us know! :)

Are there any dependencies or blockers for merging this?

No

How can we verify that this change works?

Open the PJS demo or cs/new/pjs, type rect(, see documentation pop-up.

@@ -132,37 +132,6 @@ window.LiveEditor = Backbone.View.extend({
type: this.editorType
});

var tooltipEngine = this.config.editor.tooltipEngine;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This is the feature from Gigabyte-Giant that was added when live completion was still enabled, to let people turn it off.

* Initializes the autosuggest functionality and adds/modifies the
* completers to be applicable to KA.
*/
init: function(editor) {
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The init() and enableLiveCompletion() code all revolve around the live-completion functionality, and do not relate to the documentation pop-up.

(In the React PR, I turned the rest of this file into a React component)

if (this.enabled) {
this.doRequestTooltip(e.data);
}
this.doRequestTooltip(e.data);
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I checked git history and this was the previous state.

@MatthiasPortzel
Copy link
Contributor

Personally, I really like auto suggestion, and I was disappointed when KA turned it off. This is something that has been requested for Khan Academy Extension, that was working on reenabling. I have a snippet of code that I run that re-enables auto suggestion in the live editor, and the integration with Processing's functions is very helpful. I can confirm that my code snippet no longer works and that this PR is successful in removing extra code in that regard.
When KA turned off live suggestions (commit), they did so in such a way that broke Gigabyte Giant's contribution, by turning auto suggestion off when whenever a tooltip was called. (Since autosuggestion is a tooltip, it turns itself off.)
It seems like it would be worth looking into reenabling live auto suggestions as an optional feature of the live editor (off by default, of course), rather than removing it completely.

Copy link
Member

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

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

Looks good. I do have a question about whether auto-completion is enabled at all now.

// our own completer for local variables.
for (var i = editor.completers.length - 1; i >= 0; i--) {
if (editor.completers[i] === langTools.keyWordCompleter) {
editor.completers.splice(i, 1);
Copy link
Member

Choose a reason for hiding this comment

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

Where do we turn off completers? If we aren't, won't completions appear for window, document, etc.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good Q. The function below this one used to run this code:
this.editor.setOptions({enableLiveAutocompletion:true});

That would tell ACE to turn on completion. (See https://github.com/ajaxorg/ace/blob/v1.1.4/lib/ace/ext/language_tools.js#L190)

Now that we never call that, the live completion doesn't happen.

@pamelafox
Copy link
Collaborator Author

@matthiassaihttam Thanks for chiming in! It's helpful to hear from the community. It'd be great to bring back autocompletion later. Right now, my priority for this codebase is to upgrade its underlying technologies to the modern stack that KA uses (bower to webpack, Backbone to React, etc). That will put everything in a better place so that when/if we do add features, the new code is better integrated. We wrote the Autosuggest code quickly, so it didn't have enough time to be properly architected and tested.

@pamelafox pamelafox assigned kevinbarabash and unassigned pamelafox Nov 12, 2018
@MatthiasPortzel
Copy link
Contributor

MatthiasPortzel commented Nov 13, 2018

Thanks for the answer; that makes sense.

Unless I'm mistaken, here you remove the only reference to language_tools, so you should be able to remove this line from the build dependencies. This saves 62KB from the final package size. As far as I know, Ace only uses language_tools to populate their auto suggestion, and I don't think KA uses it to populate any tooltips. And I ran the tests and didn't run into any issues locally.

@pamelafox
Copy link
Collaborator Author

pamelafox commented Nov 13, 2018 via email

Copy link
Member

@kevinbarabash kevinbarabash left a comment

Choose a reason for hiding this comment

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

LGTM.

@pamelafox pamelafox closed this Jan 5, 2023
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.

None yet

3 participants