Skip to content

Commit

Permalink
Restore old scrolling logic to address ajaxorg/cloud9#1624
Browse files Browse the repository at this point in the history
  • Loading branch information
lennartcl committed Jun 1, 2012
1 parent 1edbc07 commit b104438
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions plugins-client/ext.language/complete.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ var drawCompletionBox;
var CLASS_SELECTED = "cc_complete_option selected";
var CLASS_UNSELECTED = "cc_complete_option";
var MENU_WIDTH = 300;
var MENU_SHOWN_ITEMS = 8;
var MENU_SCROLL_AT = 4;

var deferredInvoke = lang.deferredCall(function() {
var editor = editors.currentEditor.ceEditor.$editor;
Expand Down Expand Up @@ -170,7 +170,7 @@ module.exports = {
ace.container.addEventListener("mousewheel", this.closeCompletionBox);

apf.popup.setContent("completionBox", barCompleterCont.$ext);
var boxLength = Math.max(MENU_SHOWN_ITEMS, this.matches.length || 1);
var boxLength = this.matches.length || 1;
var completionBoxHeight = 11 + Math.min(10 * this.cursorConfig.lineHeight, boxLength * (this.cursorConfig.lineHeight));
var cursorLayer = ace.renderer.$cursorLayer;

Expand Down Expand Up @@ -347,7 +347,7 @@ module.exports = {
if(this.selectedIdx < this.matches.length-1)
this.selectedIdx++;
this.matchEls[this.selectedIdx].className = CLASS_SELECTED;
if(this.selectedIdx - this.scrollIdx > MENU_SHOWN_ITEMS) {
if(this.selectedIdx - this.scrollIdx > MENU_SCROLL_AT) {
this.scrollIdx++;
this.matchEls[this.scrollIdx].scrollIntoView(true);
}
Expand All @@ -364,8 +364,8 @@ module.exports = {
return;
}
this.matchEls[this.selectedIdx].className = CLASS_SELECTED;
if(this.selectedIdx < this.scrollIdx) {
this.scrollIdx--;
if(this.selectedIdx < this.matches.length - MENU_SCROLL_AT && this.scrollIdx > 0) {
this.scrollIdx = this.selectedIdx - MENU_SCROLL_AT;
this.matchEls[this.scrollIdx].scrollIntoView(true);
}
e.stopPropagation();
Expand Down

0 comments on commit b104438

Please sign in to comment.