From e0d85e92f4c111cf231f548ec2a714e0c9c8d0fe Mon Sep 17 00:00:00 2001 From: Joe Walker Date: Mon, 5 Dec 2011 10:41:16 +0000 Subject: [PATCH] Bug 704832 (echoxml): Clarify comments, which includes extracting unclosedJs variable which slightly helps code clarity but also helps comment clarity --- lib/gcli/ui/inputter.js | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/lib/gcli/ui/inputter.js b/lib/gcli/ui/inputter.js index 17c74ce8..23c6f8f8 100644 --- a/lib/gcli/ui/inputter.js +++ b/lib/gcli/ui/inputter.js @@ -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. // // ${completionPrompt} // ${appendMarkupStatus()} // ${prefix} - // ${suffixSpanContents} + // ${contents} + // } + var document = this.element.ownerDocument; var prompt = document.createElement('span'); prompt.classList.add('gcli-prompt'); @@ -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   + contents = '\u21E5 ' + tab; // aka → the right arrow } if (prefix != null) { @@ -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); } };