Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merged with master
Browse files Browse the repository at this point in the history
  • Loading branch information
WebsiteDeveloper committed Sep 29, 2013
2 parents 0fb6c87 + d7fa08d commit 4d8924c
Show file tree
Hide file tree
Showing 55 changed files with 962 additions and 4,749 deletions.
3 changes: 2 additions & 1 deletion Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,8 @@ module.exports = function (grunt) {
shell: {
repo: grunt.option("shell-repo") || "../brackets-shell",
mac: "<%= shell.repo %>/installer/mac/staging/<%= pkg.name %>.app",
win: "<%= shell.repo %>/installer/win/staging/<%= pkg.name %>.exe"
win: "<%= shell.repo %>/installer/win/staging/<%= pkg.name %>.exe",
linux: "<%= shell.repo %>/installer/linux/debian/package-root/opt/brackets/brackets"
}
});

Expand Down
5 changes: 3 additions & 2 deletions src/brackets.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,12 +284,13 @@ define(function (require, exports, module) {
if (brackets.nativeMenus) {
$("body").addClass("has-appshell-menus");
} else {
// Prevent the menu item to grab the focus -- override focus implementation
// (issue #5310) workaround for bootstrap dropdown: prevent the menu item to grab
// the focus -- override jquery focus implementation for top-level menu items
(function () {
var defaultFocus = $.fn.focus;
$.fn.focus = function () {
if (!this.hasClass("dropdown-toggle")) {
defaultFocus.apply(this, arguments);
return defaultFocus.apply(this, arguments);
}
};
}());
Expand Down
50 changes: 49 additions & 1 deletion src/editor/CodeHintList.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ define(function (require, exports, module) {
*/
this.insertHintOnTab = insertHintOnTab;

/**
* Pending text insertion
*
* @type {string}
*/
this.pendingText = "";

/**
* The hint selection callback function
*
Expand Down Expand Up @@ -145,6 +152,26 @@ define(function (require, exports, module) {
}
};

/**
* Appends text to end of pending text.
*
* @param {string} text
*/
CodeHintList.prototype.addPendingText = function (text) {
this.pendingText += text;
};

/**
* Removes text from beginning of pending text.
*
* @param {string} text
*/
CodeHintList.prototype.removePendingText = function (text) {
if (this.pendingText.indexOf(text) === 0) {
this.pendingText = this.pendingText.slice(text.length);
}
};

/**
* Rebuilds the list items for the hint list.
*
Expand Down Expand Up @@ -346,7 +373,7 @@ define(function (require, exports, module) {

return itemsPerPage;
}

// If we're no longer visible, skip handling the key and end the session.
if (!this.isOpen()) {
this.handleClose();
Expand Down Expand Up @@ -377,6 +404,27 @@ define(function (require, exports, module) {
} else if (this.selectedIndex !== -1 &&
(keyCode === KeyEvent.DOM_VK_RETURN ||
(keyCode === KeyEvent.DOM_VK_TAB && this.insertHintOnTab))) {

if (this.pendingText) {
// Issues #5003: We received a "selection" key while there is "pending
// text". This is rare but can happen because CM uses polling, so we
// can receive key events while CM is waiting for timeout to expire.
// Pending text may dismiss the list, or it may cause a valid selection
// which keeps open hint list. We can compare pending text against
// list to determine whether list is dismissed or not, but to handle
// inserting selection in the page we'd need to either:
// 1. Synchronously force CodeMirror to poll (but there is not
// yet a public API for that).
// 2. Pass pending text back to where text gets inserted, which
// means it would need to be implemented for every HintProvider!
// You have to be typing so fast to hit this case, that's it's
// highly unlikely that inserting something from list was the intent,
// which makes this pretty rare, so case #2 is not worth implementing.
// If case #1 gets implemented, then we may want to use it here.
// So, assume that pending text dismisses hints and let event bubble.
return false;
}

// Trigger a click handler to commmit the selected item
$(this.$hintMenu.find("li")[this.selectedIndex]).trigger("click");
} else {
Expand Down
Loading

0 comments on commit 4d8924c

Please sign in to comment.