bundles/org.eclipse.orion.client.ui/web/plugins/languages/docker/dockerAssist.js
function calculateTruePrefix(buffer, offset, escapeCharacter) {
		var char = buffer.charAt(offset - 1);
		switch (char) {
			case '\n':
				var escapedPrefix = "";
				for (var i = offset - 1; i >= 0; i--) {
					if (buffer.charAt(i) === '\n') {
						if (buffer.charAt(i - 1) === escapeCharacter) {
							i--;
						} else if (buffer.charAt(i - 1) === '\r' && buffer.charAt(i - 2) === escapeCharacter) {
							i = i -2;
						} else {
							break;
						}
					} else if (buffer.charAt(i) === ' ' || buffer.charAt(i) === '\t') {
						break;
					} else {
						escapedPrefix = buffer.charAt(i).toUpperCase() + escapedPrefix;
					}
				}
				
				if (escapedPrefix !== "") {
					return escapedPrefix;
				}
				break;
			case '\r':
			case ' ':
			case '\t':
				break;
			default:
				var truePrefix = char;
				prefixCheck: for (i = offset - 2; i >= 0; i--) {
					char = buffer.charAt(i);
					switch (char) {
						case '\r':
						case '\n':
						case ' ':
						case '\t':
							break prefixCheck;
						default:
							for (i = offset - 2; i >= 0; i--) {
								truePrefix = char + truePrefix;
							}
							break;
					}
				}
				return truePrefix;
		}
		return "";
	}
function calculateTruePrefix(buffer, offset, escapeCharacter) {
		var char = buffer.charAt(offset - 1);
		switch (char) {
			case '\n':
				var escapedPrefix = "";
				for (var i = offset - 1; i >= 0; i--) {
					if (buffer.charAt(i) === '\n') {
						if (buffer.charAt(i - 1) === escapeCharacter) {
							i--;
						} else if (buffer.charAt(i - 1) === '\r' && buffer.charAt(i - 2) === escapeCharacter) {
							i = i -2;
						} else {
							break;
						}
					} else if (buffer.charAt(i) === ' ' || buffer.charAt(i) === '\t') {
						break;
					} else {
						escapedPrefix = buffer.charAt(i).toUpperCase() + escapedPrefix;
					}
				}
				
				if (escapedPrefix !== "") {
					return escapedPrefix;
				}
				break;
			case '\r':
			case ' ':
			case '\t':
				break;
			default:
				var truePrefix = char;
				prefixCheck: for (i = offset - 2; i >= 0; i--) {
					char = buffer.charAt(i);
					switch (char) {
						case '\r':
						case '\n':
						case ' ':
						case '\t':
							break prefixCheck;
						default:
							for (i = offset - 2; i >= 0; i--) {
								truePrefix = char + truePrefix;
							}
							break;
					}
				}
				return truePrefix;
		}
		return "";
	}
function calculateTruePrefix ( buffer , offset , escapeCharacter ) { var char = buffer . charAt ( offset - 1 ) ; switch ( char ) { case '\n' : var escapedPrefix = "" ; for ( var i = offset - 1 ; i >= 0 ; i -- ) { if ( buffer . charAt ( i ) === '\n' ) { if ( buffer . charAt ( i - 1 ) === escapeCharacter ) { i -- ; } else if ( buffer . charAt ( i - 1 ) === '\r' && buffer . charAt ( i - 2 ) === escapeCharacter ) { i = i - 2 ; } else { break ; } } else if ( buffer . charAt ( i ) === ' ' || buffer . charAt ( i ) === '\t' ) { break ; } else { escapedPrefix = buffer . charAt ( i ) . toUpperCase ( ) + escapedPrefix ; } } if ( escapedPrefix !== "" ) { return escapedPrefix ; } break ; case '\r' : case ' ' : case '\t' : break ; default : var truePrefix = char ; prefixCheck : for ( i = offset - 2 ; i >= 0 ; i -- ) { char = buffer . charAt ( i ) ; switch ( char ) { case '\r' : case '\n' : case ' ' : case '\t' : break prefixCheck ; default : for ( i = offset - 2 ; i >= 0 ; i -- ) { truePrefix = char + truePrefix ; } break ; } } return truePrefix ; } return "" ; }
Walks back in the text buffer to calculate the true prefix of the
current text caret offset. Orion's provided prefix does not include
symbols but we do want to consider that a prefix in Dockerfiles.

@param buffer the content of the opened file
@param offset the current text caret's offset
@param escapeCharacter the escape character defined in this Dockerfile
Walks back in the text buffer to calculate the true prefix of the current text caret offset . Orion s provided prefix does not include symbols but we do want to consider that a prefix in Dockerfiles .