<commit_before>import actions from '../actions';

const defaultState = {
  errorShown: false,
  errorText: '',
  commandShown: false,
  commandText: '',
  completions: [],
};

export default function reducer(state = defaultState, action = {}) {
  switch (action.type) {
  case actions.CONSOLE_SHOW_COMMAND:
    return Object.assign({}, state, {
      commandShown: true, 
      commandText: action.text,
      errorShown: false,
      completions: []
    });
  case actions.CONSOLE_SET_COMPLETIONS:
    return Object.assign({}, state, {
      completions: action.completions
    });
  case actions.CONSOLE_SHOW_ERROR:
    return Object.assign({}, state, {
      errorText: action.text,
      errorShown: true,
      commandShown: false,
    });
  case actions.CONSOLE_HIDE:
    return Object.assign({}, state, {
      errorShown: false,
      commandShown: false
    });
  default:
    return state;
  }
}<commit_msg>keep error message<commit_after>import actions from '../actions';

const defaultState = {
  errorShown: false,
  errorText: '',
  commandShown: false,
  commandText: '',
  completions: [],
};

export default function reducer(state = defaultState, action = {}) {
  switch (action.type) {
  case actions.CONSOLE_SHOW_COMMAND:
    return Object.assign({}, state, {
      commandShown: true, 
      commandText: action.text,
      errorShown: false,
      completions: []
    });
  case actions.CONSOLE_SET_COMPLETIONS:
    return Object.assign({}, state, {
      completions: action.completions
    });
  case actions.CONSOLE_SHOW_ERROR:
    return Object.assign({}, state, {
      errorText: action.text,
      errorShown: true,
      commandShown: false,
    });
  case actions.CONSOLE_HIDE:
    if (state.errorShown) {
      // keep error message if shown
      return state;
    }
    return Object.assign({}, state, {
      errorShown: false,
      commandShown: false
    });
  default:
    return state;
  }
}
{'fraction_non_alphanumeric': 0.12331606217616581, 'fraction_numerical': 0.0, 'mean_word_length': 3.0062240663900415, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '736714', 'n_tokens_mistral': 612, 'n_tokens_neox': 610, 'n_words': 137}