diff options
author | StefanVukovic99 <stefanvukovic44@gmail.com> | 2024-04-21 17:15:08 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-04-21 15:15:08 +0000 |
commit | 07258ecc35c1a05aa1581a54c9f47a40ce3d76c9 (patch) | |
tree | 0a73bc6c1224710906ef3cded2a19399fc626f12 /ext/js/general/regex-util.js | |
parent | 22904d166d5ea33667458ccd0fde36e77d0ff65d (diff) |
rework text processors (#793)24.4.21.0
* rework text processors
* rename text-preprocessors file
* Fix search header left margins on small screens (#839)
* Refocuses search input on backspace (#840)
Fixes #775. Note that this behavior gets overridden if backspace is set
as a shortcut action.
* Change hotkey triggering condition to account for IME usage (#837)
_isKeyCharacterInput only worked when not using an IME, as inside of an
IME when a keydown event is fired, the key is reported as "Process",
which does not have a key.length equal to 1. This resulted in hotkeys
being triggered while typing, which this commit fixes.
---------
Co-authored-by: James Maa <jmaa@berkeley.edu>
Co-authored-by: Kuuuube <61125188+Kuuuube@users.noreply.github.com>
Co-authored-by: Andrew Thomas Sartor <andrew@sartor.net>
Diffstat (limited to 'ext/js/general/regex-util.js')
-rw-r--r-- | ext/js/general/regex-util.js | 12 |
1 files changed, 1 insertions, 11 deletions
diff --git a/ext/js/general/regex-util.js b/ext/js/general/regex-util.js index e0982154..c633ec06 100644 --- a/ext/js/general/regex-util.js +++ b/ext/js/general/regex-util.js @@ -23,13 +23,12 @@ const matchReplacementPattern = /\$(?:\$|&|`|'|(\d\d?)|<([^>]*)>)/g; * Applies string.replace using a regular expression and replacement string as arguments. * A source map of the changes is also maintained. * @param {string} text A string of the text to replace. - * @param {import('./text-source-map.js').TextSourceMap} sourceMap An instance of `TextSourceMap` which corresponds to `text`. * @param {RegExp} pattern A regular expression to use as the replacement. * @param {string} replacement A replacement string that follows the format of the standard * JavaScript regular expression replacement string. * @returns {string} A new string with the pattern replacements applied and the source map updated. */ -export function applyTextReplacement(text, sourceMap, pattern, replacement) { +export function applyTextReplacement(text, pattern, replacement) { const isGlobal = pattern.global; if (isGlobal) { pattern.lastIndex = 0; } for (let loop = true; loop; loop = isGlobal) { @@ -44,15 +43,6 @@ export function applyTextReplacement(text, sourceMap, pattern, replacement) { text = `${text.substring(0, index)}${actualReplacement}${text.substring(index + matchText.length)}`; pattern.lastIndex += delta; - - if (actualReplacementLength > 0) { - /** @type {number[]} */ - const zeroes = new Array(actualReplacementLength).fill(0); - sourceMap.insert(index, ...zeroes); - sourceMap.combine(index - 1 + actualReplacementLength, matchText.length); - } else { - sourceMap.combine(index, matchText.length); - } } return text; } |