<commit_before>(function(angular) {
	var module = angular.module('net.enzey.autocomplete', ['ngSanitize']);

	var isDefined = function(value) {
		if (value !== null & value !== undefined) {
			if (angular.isNumber(value) && !isNaN(value)) {
				return true;
			}
			if (angular.isString(value) && value.trim() !== '') {
				return true;
			}
		}
		return false;
	};

	var defaultTemplateUrl = 'AutoComplete/hintTemplate.html';
	module.run(function($templateCache) {
		var defaultTemplate = '<div nz-auto-complete-hint-text></div>';
		$templateCache.put(defaultTemplateUrl, defaultTemplate);
	});

	module.directive('nzAutoCompleteHintText', function($parse) {
		return {
			restrict: 'AE',
			link: {
				post: function(scope, element, attrs) {
					var inputText = scope.ngModelCtrl.$viewValue;
					var hintText = scope.displayPath === null ? 'hint' : 'hint.' + scope.displayPath;
					var highlightRegExp =  new RegExp('(' + inputText +  ')', 'gi');
					var text = $parse(hintText)(scope);
					if (text) {
						var markedText = text.replace(highlightRegExp, '<mark>$1</mark>');

						element[0].innerHTML = markedText;
					}
				}
			}
		};
	});

	module.directive('nzAutoCompleteInclude', function($parse, $compile, $http, $templateCache) {
		return {
			restrict: 'AE',
			compile: function() {
				var directiveName = this.name;
				return function (scope, element, attr) {
					var templateUrl = $parse(attr[directiveName])(scope);
					$http.get(templateUrl, {cache: $templateCache})
					.success(function(html) {
						element.replaceWith($compile(html)(scope));
					});
				}
			}
		};
	});

	var positionAndAddScrollBar = function(hintList, inputElem) {
		hintList.css('display', 'block');
		var scroller = hintList.find('div')[0];
		if (scroller.scrollHeight > scroller.clientHeight) {
			angular.element(scroller).css('overflow-y', 'scroll');
		} else {
			angular.element(scroller).css('overflow-y', '');
		}
		hintList.css('display', '');
	};

	module.directive('nzAutoComplete', function($parse, $timeout, $compile) {
		return {
			scope: {},
			restrict: 'AE',
			controller: function($scope) {
				$scope.keyPressEvent = function(e) {
					if ($scope.selectedHintIndex !== null && (e.keyCode === 13 || e.keyCode === 9)) {
						$scope.select($scope.selectedHintIndex);
					} else if (e.keyCode === 40) {
						// key down
						if ($scope.selectedHintIndex !== null && $scope.hints.length > 1) {
							var newIndex;
							if ($scope.selectedHintIndex === $scope.hints.length - 1) {
								newIndex = 0;
							} else {
								newIndex = $scope.selectedHintIndex + 1;
							}
							$scope.selectRow(newIndex);
						}
						e.preventDefault();
						e.stopPropagation();
					} else if (e.keyCode === 38) {
						// key up
						if ($scope.selectedHintIndex !== null && $scope.hints.length > 1) {
							var newIndex;
							if ($scope.selectedHintIndex === 0) {
								newIndex = $scope.hints.length - 1;
							} else {
								newIndex = $scope.selectedHintIndex - 1;
							}
							$scope.selectRow(newIndex);
						}
						e.preventDefault();
						e.stopPropagation();
					}
				};
			},
			compile: function ($element, $attrs) {
				$element.addClass('autoComplete');

				var inputElem = $element[0].querySelector('input');
				if (inputElem) {
					inputElem = angular.element(inputElem);
				} else {
					inputElem = angular.element('<input type="text"></input>');
				}
				$element.empty();
				inputElem.removeAttr('ng-model');
				inputElem.removeAttr('data-ng-model');
				var hintInputElem = inputElem.clone();

				inputElem.addClass('textEntry');
				hintInputElem.addClass('hintBox');
				hintInputElem.attr('tabindex', '-1');
				hintInputElem.removeAttr('placeholder');

				var ngModelName = $attrs.ngModel;
				inputElem.attr('ng-model', ngModelName);

				var wrapper = angular.element('<div></div>');
				$element.append(hintInputElem);
				$element.append(angular.element('<iframe></iframe>'));
				$element.append(inputElem);
				$element.append(angular.element('<div class="loadingIndicator"></div>'));

				return {
					pre: function(scope, element, attrs) {
						scope.hints = [];

						var templateUrl = isDefined(attrs.templateUrl) ? attrs.templateUrl : "'" + defaultTemplateUrl + "'";
						var hintList = $compile('\
							<div class="scrollerContainer">\
								<iframe></iframe>\
								<div class="scroller" ng-hide="hints.length < 2">\
									<div class="hint"\
											ng-repeat="hint in hints"\
											ng-click="select($index)"\
											ng-mouseover="hoverOver($index)"\
											ng-class="{selectedHint: $index === selectedHintIndex}">\
										<div nz-auto-complete-include="' + templateUrl + '"></div>\
									</div>\
								</div>\
								<div class="scroller noResults">\
									<span class="noResults hint">{{noResultsText}}</span>\
								</div>\
							</div>\
						')(scope);<commit_msg>Dipslay suggestion list when only one entry exists.<commit_after>(function(angular) {
	var module = angular.module('net.enzey.autocomplete', ['ngSanitize']);

	var isDefined = function(value) {
		if (value !== null & value !== undefined) {
			if (angular.isNumber(value) && !isNaN(value)) {
				return true;
			}
			if (angular.isString(value) && value.trim() !== '') {
				return true;
			}
		}
		return false;
	};

	var defaultTemplateUrl = 'AutoComplete/hintTemplate.html';
	module.run(function($templateCache) {
		var defaultTemplate = '<div nz-auto-complete-hint-text></div>';
		$templateCache.put(defaultTemplateUrl, defaultTemplate);
	});

	module.directive('nzAutoCompleteHintText', function($parse) {
		return {
			restrict: 'AE',
			link: {
				post: function(scope, element, attrs) {
					var inputText = scope.ngModelCtrl.$viewValue;
					var hintText = scope.displayPath === null ? 'hint' : 'hint.' + scope.displayPath;
					var highlightRegExp =  new RegExp('(' + inputText +  ')', 'gi');
					var text = $parse(hintText)(scope);
					if (text) {
						var markedText = text.replace(highlightRegExp, '<mark>$1</mark>');

						element[0].innerHTML = markedText;
					}
				}
			}
		};
	});

	module.directive('nzAutoCompleteInclude', function($parse, $compile, $http, $templateCache) {
		return {
			restrict: 'AE',
			compile: function() {
				var directiveName = this.name;
				return function (scope, element, attr) {
					var templateUrl = $parse(attr[directiveName])(scope);
					$http.get(templateUrl, {cache: $templateCache})
					.success(function(html) {
						element.replaceWith($compile(html)(scope));
					});
				}
			}
		};
	});

	var positionAndAddScrollBar = function(hintList, inputElem) {
		hintList.css('display', 'block');
		var scroller = hintList.find('div')[0];
		if (scroller.scrollHeight > scroller.clientHeight) {
			angular.element(scroller).css('overflow-y', 'scroll');
		} else {
			angular.element(scroller).css('overflow-y', '');
		}
		hintList.css('display', '');
	};

	module.directive('nzAutoComplete', function($parse, $timeout, $compile) {
		return {
			scope: {},
			restrict: 'AE',
			controller: function($scope) {
				$scope.keyPressEvent = function(e) {
					if ($scope.selectedHintIndex !== null && (e.keyCode === 13 || e.keyCode === 9)) {
						$scope.select($scope.selectedHintIndex);
					} else if (e.keyCode === 40) {
						// key down
						if ($scope.selectedHintIndex !== null && $scope.hints.length > 1) {
							var newIndex;
							if ($scope.selectedHintIndex === $scope.hints.length - 1) {
								newIndex = 0;
							} else {
								newIndex = $scope.selectedHintIndex + 1;
							}
							$scope.selectRow(newIndex);
						}
						e.preventDefault();
						e.stopPropagation();
					} else if (e.keyCode === 38) {
						// key up
						if ($scope.selectedHintIndex !== null && $scope.hints.length > 1) {
							var newIndex;
							if ($scope.selectedHintIndex === 0) {
								newIndex = $scope.hints.length - 1;
							} else {
								newIndex = $scope.selectedHintIndex - 1;
							}
							$scope.selectRow(newIndex);
						}
						e.preventDefault();
						e.stopPropagation();
					}
				};
			},
			compile: function ($element, $attrs) {
				$element.addClass('autoComplete');

				var inputElem = $element[0].querySelector('input');
				if (inputElem) {
					inputElem = angular.element(inputElem);
				} else {
					inputElem = angular.element('<input type="text"></input>');
				}
				$element.empty();
				inputElem.removeAttr('ng-model');
				inputElem.removeAttr('data-ng-model');
				var hintInputElem = inputElem.clone();

				inputElem.addClass('textEntry');
				hintInputElem.addClass('hintBox');
				hintInputElem.attr('tabindex', '-1');
				hintInputElem.removeAttr('placeholder');

				var ngModelName = $attrs.ngModel;
				inputElem.attr('ng-model', ngModelName);

				var wrapper = angular.element('<div></div>');
				$element.append(hintInputElem);
				$element.append(angular.element('<iframe></iframe>'));
				$element.append(inputElem);
				$element.append(angular.element('<div class="loadingIndicator"></div>'));

				return {
					pre: function(scope, element, attrs) {
						scope.hints = [];

						var templateUrl = isDefined(attrs.templateUrl) ? attrs.templateUrl : "'" + defaultTemplateUrl + "'";
						var hintList = $compile('\
							<div class="scrollerContainer">\
								<iframe></iframe>\
								<div class="scroller" ng-hide="hints.length < 1">\
									<div class="hint"\
											ng-repeat="hint in hints"\
											ng-click="select($index)"\
											ng-mouseover="hoverOver($index)"\
											ng-class="{selectedHint: $index === selectedHintIndex}">\
										<div nz-auto-complete-include="' + templateUrl + '"></div>\
									</div>\
								</div>\
								<div class="scroller noResults">\
									<span class="noResults hint">{{noResultsText}}</span>\
								</div>\
							</div>\
						')(scope);
{'fraction_non_alphanumeric': 0.17327235772357724, 'fraction_numerical': 0.00426829268292683, 'mean_word_length': 3.018374846876276, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 61, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2805970', 'n_tokens_mistral': 4127, 'n_tokens_neox': 3059, 'n_words': 552}