diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2020-01-09 05:45:10 +0300 |
---|---|---|
committer | Rich Trott <rtrott@gmail.com> | 2020-01-12 01:06:33 +0300 |
commit | 5baae143c7be58e7ea64f15ccab5c2e09afd7e0b (patch) | |
tree | cfa1948bea5f505c36c70ebf1ae05f6ab8f776de /lib/internal/readline | |
parent | a52328310c2c7a399a701c8c78dc4f1fda654c95 (diff) |
readline: improve unicode support and tab completion
1. This reduces the number of write operations used during tab
completion.
2. The tab completion calculated the string width using the length
of the string instead of using the actual width. That is fixed.
3. The key decoder is now capable of handling characters composed
out of two code points. That reduces the number of "keypress"
events that are emitted which again lowers the amount of writes
triggered.
PR-URL: https://github.com/nodejs/node/pull/31288
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'lib/internal/readline')
-rw-r--r-- | lib/internal/readline/utils.js | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/lib/internal/readline/utils.js b/lib/internal/readline/utils.js index 3257ee3a1e4..b867dec0cdb 100644 --- a/lib/internal/readline/utils.js +++ b/lib/internal/readline/utils.js @@ -163,7 +163,6 @@ function stripVTControlCharacters(str) { return str.replace(ansi, ''); } - /* Some patterns seen in terminal key escape codes, derived from combos seen at http://www.midnight-commander.org/browser/lib/tty/key.c @@ -450,7 +449,7 @@ function* emitKeys(stream) { if (s.length !== 0 && (key.name !== undefined || escaped)) { /* Named character or sequence */ stream.emit('keypress', escaped ? undefined : s, key); - } else if (s.length === 1) { + } else if (charLengthAt(s, 0) === s.length) { /* Single unnamed character, e.g. "." */ stream.emit('keypress', s, key); } |