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

Added logic to control autocomplete #678

Merged
merged 11 commits into from
Apr 6, 2017
Merged

Conversation

hkirat
Copy link

@hkirat hkirat commented Mar 31, 2017

In reference to #1920.
The P.R. adds logic to handle toggling of auto complete

@hkirat hkirat changed the title Added logic to allow toggling of auto-complete Added logic to control auto-complete Apr 2, 2017
@Pomax
Copy link

Pomax commented Apr 3, 2017

@hkirat your comment points to an issue in the Adobe/brackets repository, did you mean to point to a Thimble repository? If so, note that if you want to point to an issue in a different repo, you can't use the #... formatting, you need to use the full URL for that issue

@hkirat
Copy link
Author

hkirat commented Apr 3, 2017

Thanks for pointing that out @Pomax. It points to an issue in Thimble. Updated the same.

@flukeout
Copy link

flukeout commented Apr 5, 2017

@hkirat thanks for the update testing now.

@@ -909,6 +920,14 @@ define([
this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_DISABLE_SCRIPTS"}, callback);
};

BrambleProxy.prototype.startAutoComplete = function(callback) {
Copy link

Choose a reason for hiding this comment

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

Please change this to enable vs. start

this._executeRemoteCommand({commandCategory: "bramble", command: "START_AUTO_COMPLETE"}, callback);
};

BrambleProxy.prototype.stopAutoComplete = function(callback) {
Copy link

Choose a reason for hiding this comment

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

Please change this to disable vs. start

@@ -204,6 +204,7 @@ define([
self.getSidebarVisible = function() { return _state.sidebarVisible; };
self.getRootDir = function() { return _root; };
self.getWordWrap = function() { return _state.wordWrap; };
self.getAutoComplete = function() { return _state.allowAutoComplete; };
Copy link

Choose a reason for hiding this comment

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

Because you're changing the public API, please update the README as well, see https://github.com/mozilla/brackets#bramble-instance-getters

@@ -157,6 +157,40 @@ define(function (require, exports, module) {
});
});

// Listen for changes to TagHints
PreferencesManager.on("change", "codehint.TagHints", function () {
Copy link

Choose a reason for hiding this comment

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

I don't like the idea of sending 4 separate events for state changes on a variable that we're tracking in the StateManager as a single boolean. Can you harmonize these so they all send the same type: "bramble:autocompleteChange" with a single boolean? It will mean we fire this change event 4 times, but that shouldn't break anything, since Thimble will just set it true or false in all cases.

@@ -139,6 +139,10 @@ define(function() {
get: function() { return getBool(storage, "allowJavaScript"); },
set: function(v) { storage.setItem(prefix("allowJavaScript"), v); }
},
allowAutoComplete: {
Copy link

Choose a reason for hiding this comment

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

I have a general concern. In some places you use Autocomplete and in others AutoComplete. Once upon a time I implemented a bunch of code in Firefox related to the FullScreen API which later became the Fullscreen API, and it left me very nervous about the bugs that can creep in with such inconsistencies. When I Google this, most people seem to use "Autocomplete." Should we do that everywhere? I actually don't care as long as we're consistent in all places, here and in Thimble.

@@ -309,6 +311,14 @@ define([
_state.allowJavaScript = data.allowJavaScript;
} else if (eventName === "tutorialVisibilityChange") {
_tutorialVisible = data.visible;
} else if (eventName === "TagHintsChange") {
Copy link

Choose a reason for hiding this comment

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

This is a leaky abstraction, and I'd like to harmonize these event types into a single autoCompleteChange event. See my comment below.

@hkirat hkirat changed the title Added logic to control auto-complete Added logic to control autocomplete Apr 6, 2017
@hkirat
Copy link
Author

hkirat commented Apr 6, 2017

Thanks for the review @humphd
I really should've kept track of the variable names. Apologies for that.
I've shifted to a common convention of autocomplete now.

Copy link

@humphd humphd left a comment

Choose a reason for hiding this comment

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

Two small wording changes, and this is ready to go! Great work.

@@ -909,6 +914,14 @@ define([
this._executeRemoteCommand({commandCategory: "bramble", command: "BRAMBLE_DISABLE_SCRIPTS"}, callback);
};

BrambleProxy.prototype.enableAutocomplete = function(callback) {
this._executeRemoteCommand({commandCategory: "bramble", command: "START_AUTO_COMPLETE"}, callback);
Copy link

Choose a reason for hiding this comment

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

change the command name to BRAMBLE_ENABLE_AUTOCOMPLETE

};

BrambleProxy.prototype.disableAutocomplete = function(callback) {
this._executeRemoteCommand({commandCategory: "bramble", command: "STOP_AUTO_COMPLETE"}, callback);
Copy link

Choose a reason for hiding this comment

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

change the command name to BRAMBLE_DISABLE_AUTOCOMPLETE

@hkirat
Copy link
Author

hkirat commented Apr 6, 2017

Sorry I missed that.
Fixed now

@humphd humphd merged commit 2d99ca7 into mozilla:master Apr 6, 2017
@humphd
Copy link

humphd commented Apr 6, 2017

Excellent work, @hkirat, thank you!

A note for Thimble devs about this change. This PR, along with similar ones in process right now, makes changes to the code used to create dist/bramble.js. Thimble uses this file in order to communicate with Brackets, and unless you manually rebuild it, it won't have the new code. A common error is bramble.someMethod() is not a function. It means you need to update Brackets. Here is the recommended way to do it:

git checkout master
git pull upstream master
git submodule update --init
npm install
npm run build

Updating your submodules and npm modules is not strictly necessary in this case, but it also won't hurt (i.e., it's always safe to do these two things). The final line npm run build will recreate dist/bramble.js with the new code, and will allow Thimble to find it.

If you do all this and Thimble still can find the function in needs on the bramble object, you probably need to clear your cache in Thimble so it forces it to reload dist/bramble.js.

timmoy pushed a commit to timmoy/brackets that referenced this pull request Apr 19, 2017
* Included new state in StateManager.js

* Added events to implement AutoComplete toggle

* Added start and stop functions in bramble

* Added allowAutoCorrect to main.js

* Fixes typos

* Added toggle functionality to JS and CSS hints

* Changed all variable names to Autocomplete

* Emitted a single event(autocompleteChange) when Hints Change

* Added note in README related to new getAutocomplete function

* Modified Remote Command Strings
timmoy pushed a commit to timmoy/brackets that referenced this pull request Apr 20, 2017
* Included new state in StateManager.js

* Added events to implement AutoComplete toggle

* Added start and stop functions in bramble

* Added allowAutoCorrect to main.js

* Fixes typos

* Added toggle functionality to JS and CSS hints

* Changed all variable names to Autocomplete

* Emitted a single event(autocompleteChange) when Hints Change

* Added note in README related to new getAutocomplete function

* Modified Remote Command Strings
Rajat-dhyani pushed a commit to Rajat-dhyani/brackets that referenced this pull request Apr 20, 2017
* Included new state in StateManager.js

* Added events to implement AutoComplete toggle

* Added start and stop functions in bramble

* Added allowAutoCorrect to main.js

* Fixes typos

* Added toggle functionality to JS and CSS hints

* Changed all variable names to Autocomplete

* Emitted a single event(autocompleteChange) when Hints Change

* Added note in README related to new getAutocomplete function

* Modified Remote Command Strings
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