Skip to content

Commit

Permalink
fix(list): improve handling of whitespaces on remove word (#5137) (#5138
Browse files Browse the repository at this point in the history
)
  • Loading branch information
statiolake committed Sep 6, 2024
1 parent 640544d commit f3406e0
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/list/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,9 @@ export default class Prompt {
if (cusorIndex == 0) return
let pre = input.slice(0, cusorIndex)
let post = input.slice(cusorIndex)
let remain = pre.replace(/[\w\s$\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]+([^\w\s$\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]+)?$/u, '')
let remain = pre
.trimEnd() // to remove last whitespaces
.replace(/[\w$\p{Script=Han}\p{Script=Hiragana}\p{Script=Katakana}]+$/u, '') // to remove the last word
this.cusorIndex = cusorIndex - (pre.length - remain.length)
this._input = `${remain}${post}`
this.drawPrompt()
Expand Down

0 comments on commit f3406e0

Please sign in to comment.