<commit_before>'use strict';

const colors = require('ansi-colors');
const utils = require('./utils');

/**
 * Render a placeholder value with cursor and styling based on the
 * position of the cursor. This function creates the illusion that
 *
 *
 * @param {Object} `prompt` Prompt instance
 * @param {String} `input`
 * @param {String} `initial`
 * @param {Number} `pos`
 * @param {Boolean} `showCursor`
 * @return {String} Returns the styled placeholder string.
 * @api public
 */

module.exports = (prompt, input = '', initial = '', pos, showCursor = true) => {
  let inverse = utils.inverse(prompt.styles.primary);
  let output = input;

  initial = utils.isPrimitive(initial) ? `${initial}` : '';
  input = utils.isPrimitive(input) ? `${input}` : '';

  if (!initial) {
    return input;
  }

  let placeholder = initial && initial.startsWith(input) && initial !== input;
  let cursor = placeholder ? inverse(colors.black(initial[input.length])) : inverse(' ');

  if (pos !== input.length && showCursor === true) {
    output = input.slice(0, pos) + inverse(colors.black(input[pos])) + input.slice(pos + 1);
    cursor = '';
  }

  if (showCursor === false) {
    cursor = '';
  }

  if (placeholder) {
    let raw = colors.unstyle(output + cursor);
    return output + cursor + prompt.styles.placeholder(initial.slice(raw.length));
  }

  return output + cursor;
};
<commit_msg>ensure cursor style is displayed<commit_after>'use strict';

const colors = require('ansi-colors');
const utils = require('./utils');

/**
 * Render a placeholder value with cursor and styling based on the
 * position of the cursor. This function creates the illusion that
 *
 *
 * @param {Object} `prompt` Prompt instance
 * @param {String} `input`
 * @param {String} `initial`
 * @param {Number} `pos`
 * @param {Boolean} `showCursor`
 * @return {String} Returns the styled placeholder string.
 * @api public
 */

module.exports = (prompt, input = '', initial = '', pos, showCursor = true) => {
  prompt.cursorHide();

  let inverse = utils.inverse(prompt.styles.primary);
  let output = input;

  initial = utils.isPrimitive(initial) ? `${initial}` : '';
  input = utils.isPrimitive(input) ? `${input}` : '';

  let placeholder = initial && initial.startsWith(input) && initial !== input;
  let cursor = placeholder ? inverse(colors.black(initial[input.length])) : inverse(' ');

  if (pos !== input.length && showCursor === true) {
    output = input.slice(0, pos) + inverse(colors.black(input[pos])) + input.slice(pos + 1);
    cursor = '';
  }

  if (showCursor === false) {
    cursor = '';
  }

  if (placeholder) {
    let raw = colors.unstyle(output + cursor);
    return output + cursor + prompt.styles.placeholder(initial.slice(raw.length));
  }

  return output + cursor;
};

{'fraction_non_alphanumeric': 0.1643835616438356, 'fraction_numerical': 0.0014419610670511895, 'mean_word_length': 3.894179894179894, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '7275855', 'n_tokens_mistral': 833, 'n_tokens_neox': 830, 'n_words': 237}