Skip to content
This repository has been archived by the owner on Jun 28, 2022. It is now read-only.

Commit

Permalink
Bug 704832 (echoxml): Clarify comments, which includes
Browse files Browse the repository at this point in the history
extracting unclosedJs variable which slightly helps code clarity
but also helps comment clarity
  • Loading branch information
joewalker committed Dec 5, 2011
1 parent 08fd778 commit e0d85e9
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions lib/gcli/ui/inputter.js
Expand Up @@ -551,14 +551,17 @@ Completer.prototype.update = function(input) {

dom.clearElement(this.element);

// All this DOM manipulation is equivalent to the following template. It's
// not in a template because appendMarkupStatus() needs to merge spans.
// All this DOM manipulation is equivalent to the HTML below.
// It's not a template because it's very simple except appendMarkupStatus()
// which is complex due to a need to merge spans.
// Bug 707131 questions if we couldn't simplify this to use a template.
//
// <span class="gcli-prompt">${completionPrompt}</span>
// ${appendMarkupStatus()}
// ${prefix}
// <span class="gcli-in-ontab">${suffixSpanContents}</span>
// <span class="gcli-in-ontab">${contents}</span>
// <span class="gcli-in-closebrace" if="${unclosedJs}">}<span>

var document = this.element.ownerDocument;
var prompt = document.createElement('span');
prompt.classList.add('gcli-prompt');
Expand All @@ -584,8 +587,8 @@ Completer.prototype.update = function(input) {
contents = tab.slice(existing.length - numLeadingSpaces);
} else {
// Display the '-> prediction' at the end of the completer element
prefix = ' \u00a0';
contents = '\u21E5 ' + tab;
prefix = ' \u00a0'; // aka &nbsp;
contents = '\u21E5 ' + tab; // aka &rarr; the right arrow
}

if (prefix != null) {
Expand All @@ -598,16 +601,16 @@ Completer.prototype.update = function(input) {
this.element.appendChild(suffix);
}

// A hack to add a grey '}' to the end of the command line when we've opened
// Add a grey '}' to the end of the command line when we've opened
// with a { but haven't closed it
var command = this.requisition.commandAssignment.getValue();
if (command && command.name === '{') {
if (this.requisition.getAssignment(0).getArg().suffix.indexOf('}') === -1) {
var close = document.createElement('span');
close.classList.add('gcli-in-closebrace');
close.appendChild(document.createTextNode('}'));
this.element.appendChild(close);
}
var unclosedJs = command && command.name === '{' &&
this.requisition.getAssignment(0).getArg().suffix.indexOf('}') === -1;
if (unclosedJs) {
var close = document.createElement('span');
close.classList.add('gcli-in-closebrace');
close.appendChild(document.createTextNode('}'));
this.element.appendChild(close);
}
};

Expand Down

0 comments on commit e0d85e9

Please sign in to comment.