microsoft / vscode

Visual Studio Code
https://code.visualstudio.com
MIT License
160.61k stars 28.14k forks source link

Find-in-file -> regexp -> using an escaped new line causes freeze until timeout crash prompt. #175683

Closed veloper closed 1 year ago

veloper commented 1 year ago

Type: Bug

1) open a new file 2) paste in the code below. 3) cmd+f 4) select regex toggle button 5) enter in \/\*(.+?)\*\/ -- all should be well 6) now attempt to add an escaped new line into the subselect like so... 7) enter in \/\*(.+?|\n)\*\/ -- right on key-up from the n key it stalls and hangs until the [re-open] or [keep waiting] prompt appears.

/**
 * lodash (Custom Build) <https://lodash.com/>
 * Build: `lodash modularize exports="npm" -o ./`
 * Copyright jQuery Foundation and other contributors <https://jquery.org/>
 * Released under MIT license <https://lodash.com/license>
 * Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
 * Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
 */

/** Used as references for various `Number` constants. */
var INFINITY = 1 / 0,
    MAX_SAFE_INTEGER = 9007199254740991;

/** `Object#toString` result references. */
var argsTag = '[object Arguments]',
    funcTag = '[object Function]',
    genTag = '[object GeneratorFunction]';

/** Detect free variable `global` from Node.js. */
var freeGlobal = typeof global == 'object' && global && global.Object === Object && global;

/** Detect free variable `self`. */
var freeSelf = typeof self == 'object' && self && self.Object === Object && self;

/** Used as a reference to the global object. */
var root = freeGlobal || freeSelf || Function('return this')();

/**
 * Appends the elements of `values` to `array`.
 *
 * @private
 * @param {Array} array The array to modify.
 * @param {Array} values The values to append.
 * @returns {Array} Returns `array`.
 */
function arrayPush(array, values) {
  var index = -1,
      length = values.length,
      offset = array.length;

  while (++index < length) {
    array[offset + index] = values[index];
  }
  return array;
}

/** Used for built-in method references. */
var objectProto = Object.prototype;

/** Used to check objects for own properties. */
var hasOwnProperty = objectProto.hasOwnProperty;

var objectToString = objectProto.toString;

/** Built-in value references. */
var Symbol = root.Symbol,
    propertyIsEnumerable = objectProto.propertyIsEnumerable,
    spreadableSymbol = Symbol ? Symbol.isConcatSpreadable : undefined;

/**
 * The base implementation of `_.flatten` with support for restricting flattening.
 *
 * @private
 * @param {Array} array The array to flatten.
 * @param {number} depth The maximum recursion depth.
 * @param {boolean} [predicate=isFlattenable] The function invoked per iteration.
 * @param {boolean} [isStrict] Restrict to values that pass `predicate` checks.
 * @param {Array} [result=[]] The initial result value.
 * @returns {Array} Returns the new flattened array.
 */
function baseFlatten(array, depth, predicate, isStrict, result) {
  var index = -1,
      length = array.length;

  predicate || (predicate = isFlattenable);
  result || (result = []);

  while (++index < length) {
    var value = array[index];
    if (depth > 0 && predicate(value)) {
      if (depth > 1) {
        // Recursively flatten arrays (susceptible to call stack limits).
        baseFlatten(value, depth - 1, predicate, isStrict, result);
      } else {
        arrayPush(result, value);
      }
    } else if (!isStrict) {
      result[result.length] = value;
    }
  }
  return result;
}

/**
 * Checks if `value` is a flattenable `arguments` object or array.
 *
 * @private
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is flattenable, else `false`.
 */
function isFlattenable(value) {
  return isArray(value) || isArguments(value) ||
    !!(spreadableSymbol && value && value[spreadableSymbol]);
}

/**
 * Recursively flattens `array`.
 *
 * @static
 * @memberOf _
 * @since 3.0.0
 * @category Array
 * @param {Array} array The array to flatten.
 * @returns {Array} Returns the new flattened array.
 * @example
 *
 * _.flattenDeep([1, [2, [3, [4]], 5]]);
 * // => [1, 2, 3, 4, 5]
 */
function flattenDeep(array) {
  var length = array ? array.length : 0;
  return length ? baseFlatten(array, INFINITY) : [];
}

/**
 * Checks if `value` is likely an `arguments` object.
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @category Lang
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is an `arguments` object,
 *  else `false`.
 * @example
 *
 * _.isArguments(function() { return arguments; }());
 * // => true
 *
 * _.isArguments([1, 2, 3]);
 * // => false
 */
function isArguments(value) {
  // Safari 8.1 makes `arguments.callee` enumerable in strict mode.
  return isArrayLikeObject(value) && hasOwnProperty.call(value, 'callee') &&
    (!propertyIsEnumerable.call(value, 'callee') || objectToString.call(value) == argsTag);
}

/**
 * Checks if `value` is classified as an `Array` object.
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @category Lang
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is an array, else `false`.
 * @example
 *
 * _.isArray([1, 2, 3]);
 * // => true
 *
 * _.isArray(document.body.children);
 * // => false
 *
 * _.isArray('abc');
 * // => false
 *
 * _.isArray(_.noop);
 * // => false
 */
var isArray = Array.isArray;

/**
 * Checks if `value` is array-like. A value is considered array-like if it's
 * not a function and has a `value.length` that's an integer greater than or
 * equal to `0` and less than or equal to `Number.MAX_SAFE_INTEGER`.
 *
 * @static
 * @memberOf _
 * @since 4.0.0
 * @category Lang
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is array-like, else `false`.
 * @example
 *
 * _.isArrayLike([1, 2, 3]);
 * // => true
 *
 * _.isArrayLike(document.body.children);
 * // => true
 *
 * _.isArrayLike('abc');
 * // => true
 *
 * _.isArrayLike(_.noop);
 * // => false
 */
function isArrayLike(value) {
  return value != null && isLength(value.length) && !isFunction(value);
}

/**
 * This method is like `_.isArrayLike` except that it also checks if `value`
 * is an object.
 *
 * @static
 * @memberOf _
 * @since 4.0.0
 * @category Lang
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is an array-like object,
 *  else `false`.
 * @example
 *
 * _.isArrayLikeObject([1, 2, 3]);
 * // => true
 *
 * _.isArrayLikeObject(document.body.children);
 * // => true
 *
 * _.isArrayLikeObject('abc');
 * // => false
 *
 * _.isArrayLikeObject(_.noop);
 * // => false
 */
function isArrayLikeObject(value) {
  return isObjectLike(value) && isArrayLike(value);
}

/**
 * Checks if `value` is classified as a `Function` object.
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @category Lang
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is a function, else `false`.
 * @example
 *
 * _.isFunction(_);
 * // => true
 *
 * _.isFunction(/abc/);
 * // => false
 */
function isFunction(value) {
  // The use of `Object#toString` avoids issues with the `typeof` operator
  // in Safari 8-9 which returns 'object' for typed array and other constructors.
  var tag = isObject(value) ? objectToString.call(value) : '';
  return tag == funcTag || tag == genTag;
}

/**
 * Checks if `value` is a valid array-like length.
 *
 * **Note:** This method is loosely based on
 * [`ToLength`](http://ecma-international.org/ecma-262/7.0/#sec-tolength).
 *
 * @static
 * @memberOf _
 * @since 4.0.0
 * @category Lang
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is a valid length, else `false`.
 * @example
 *
 * _.isLength(3);
 * // => true
 *
 * _.isLength(Number.MIN_VALUE);
 * // => false
 *
 * _.isLength(Infinity);
 * // => false
 *
 * _.isLength('3');
 * // => false
 */
function isLength(value) {
  return typeof value == 'number' &&
    value > -1 && value % 1 == 0 && value <= MAX_SAFE_INTEGER;
}

/**
 * Checks if `value` is the
 * [language type](http://www.ecma-international.org/ecma-262/7.0/#sec-ecmascript-language-types)
 * of `Object`. (e.g. arrays, functions, objects, regexes, `new Number(0)`, and `new String('')`)
 *
 * @static
 * @memberOf _
 * @since 0.1.0
 * @category Lang
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is an object, else `false`.
 * @example
 *
 * _.isObject({});
 * // => true
 *
 * _.isObject([1, 2, 3]);
 * // => true
 *
 * _.isObject(_.noop);
 * // => true
 *
 * _.isObject(null);
 * // => false
 */
function isObject(value) {
  var type = typeof value;
  return !!value && (type == 'object' || type == 'function');
}

/**
 * Checks if `value` is object-like. A value is object-like if it's not `null`
 * and has a `typeof` result of "object".
 *
 * @static
 * @memberOf _
 * @since 4.0.0
 * @category Lang
 * @param {*} value The value to check.
 * @returns {boolean} Returns `true` if `value` is object-like, else `false`.
 * @example
 *
 * _.isObjectLike({});
 * // => true
 *
 * _.isObjectLike([1, 2, 3]);
 * // => true
 *
 * _.isObjectLike(_.noop);
 * // => false
 *
 * _.isObjectLike(null);
 * // => false
 */
function isObjectLike(value) {
  return !!value && typeof value == 'object';
}

export default flattenDeep;

VS Code version: Code 1.75.1 (Universal) (441438abd1ac652551dbe4d408dfcec8a499b8bf, 2023-02-08T21:34:59.000Z) OS version: Darwin arm64 21.6.0 Modes: Sandboxed: No

System Info |Item|Value| |---|---| |CPUs|Apple M1 Max (10 x 24)| |GPU Status|2d_canvas: enabled
canvas_oop_rasterization: disabled_off
direct_rendering_display_compositor: disabled_off_ok
gpu_compositing: enabled
metal: disabled_off
multiple_raster_threads: enabled_on
opengl: enabled_on
rasterization: enabled
raw_draw: disabled_off_ok
skia_renderer: enabled_on
video_decode: enabled
video_encode: enabled
vulkan: disabled_off
webgl: enabled
webgl2: enabled
webgpu: disabled_off| |Load (avg)|9, 6, 5| |Memory (System)|32.00GB (1.11GB free)| |Process Argv|| |Screen Reader|no| |VM|0%|
Extensions (91) Extension|Author (truncated)|Version ---|---|--- go-outliner|766|0.1.20 output-link-to-file|93a|0.0.17 increment-selection|alb|0.2.0 project-manager|ale|12.7.0 aws-toolkit-vscode|ama|1.63.0 All-Autocomplete|Ati|0.0.26 scratchpads|bue|1.0.0 npm-intellisense|chr|1.4.4 path-intellisense|chr|2.8.4 gitignore|cod|0.9.0 vscode-svgviewer|css|2.0.0 vscode-mysql-client2|cwe|6.2.3 vscode-quick-select|dba|0.2.9 npm-browser|den|1.1.4 githistory|don|0.6.19 gitlens|eam|13.3.1 vscode-toggle-column-selection|eri|1.0.6 font-switcher|eva|4.1.0 auto-close-tag|for|0.5.14 auto-rename-tag|for|0.1.10 jira-plugin|gio|0.22.2 go|gol|0.37.1 vscode-test-explorer|hbe|2.21.1 output-colorizer|IBM|0.1.2 prettier-sql-vscode|inf|1.6.0 backbone-js-snippets|ioa|0.0.1 path-autocomplete|ion|1.23.1 vscode-edit-csv|jan|0.7.3 vscode-go-template|jin|0.2.1 postgresql|JPT|0.0.2 intellij-idea-keybindings|k--|1.5.5 move-selection-to-new-file|ken|1.0.1 auto-comment-blocks|kev|1.0.1 wrapSelection|kon|0.10.0 node-module-intellisense|lei|1.5.0 bash-ide-vscode|mad|1.33.0 string-manipulation|mar|0.5.7 identical-sublime-monokai-csharp-theme-colorizer|max|1.2.3 go-struct-tag-autogen|max|1.1.1 rainbow-csv|mec|3.5.0 git-graph|mhu|1.30.0 vscode-checkpoints|mic|1.3.3 bigquery-runner|min|1.21.1 vscode-duplicate|mrm|1.2.1 vscode-docker|ms-|1.24.0 isort|ms-|2022.8.0 python|ms-|2023.2.0 vscode-pylance|ms-|2023.2.40 remote-containers|ms-|0.275.1 cpptools|ms-|1.14.3 makefile-tools|ms-|0.6.0 sublime-keybindings|ms-|4.0.10 test-adapter-converter|ms-|0.1.6 go-doc|msy|1.0.1 sqltools|mtx|0.27.1 sqltools-driver-mysql|mtx|0.5.1 sqltools-driver-pg|mtx|0.5.1 gotools|neo|0.0.7 gremlins|nho|0.26.0 lowlight-go-errors|oha|1.3.0 go-inline-pgformatter|pas|1.0.3 vscode-intellij-recent-files|per|1.1.1 material-icon-theme|PKi|4.24.0 text-power-tools|qcz|1.40.1 gitlink|qez|1.2.4 inline-sql-syntax|quf|2.16.0 quicktype|qui|12.0.46 gomodexplorer|r3i|0.3.9 vscode-yaml|red|1.11.0 vscode-sort-json|ric|1.20.0 color-manager|roy|0.7.5 annotator|ryu|1.0.0 partial-diff|ryu|1.4.3 vscode-proto|san|0.0.6 markdown-preview-enhanced|shd|0.6.7 sql-bigquery|shi|1.9.0 indenticator|Sir|0.7.0 snp-go-basic|sni|0.1.0 vscode-taskexplorer|spm|2.13.2 code-spell-checker|str|2.18.0 tabnine-vscode|Tab|3.6.41 open-in-browser|tec|2.0.0 autocomplate-shell|tru|0.1.1 sort-lines|Tyr|1.9.1 errorlens|use|3.7.0 vscode-icons|vsc|12.2.0 local-history|xyz|1.8.1 cursor-align|yo1|1.1.0 vscode-postfix-go|yok|0.0.12 json|Zai|2.0.2 vscode-proto3|zxh|0.5.5 (2 theme extensions excluded)
IllusionMH commented 1 year ago

Unable to reproduce problem with given regexps (but in VS Code Insiders on Windows 10).

Do you have an additional * or + after )?

VSCodeTriageBot commented 1 year ago

This issue has been closed automatically because it needs more information and has not had recent activity. See also our issue reporting guidelines.

Happy Coding!