Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

vi-mode - Bug - Fix freeze when using _i"/_a" in escaped string #1716

Merged
merged 1 commit into from
Dec 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 13 additions & 4 deletions extensions/vi-mode/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,18 @@ Here's a list of all options currently implemented:
* Default: `nil` (don't show)
* Aliases: `nu`

## Unittests

```
## Unit Tests

### Command Line

```bash
qlot install
.qlot/bin/rove extensions/vi-mode/lem-vi-mode.asd
```
```

### In Lem

Use `C-c C-r` or:
```common-lisp Example Test
(rove:run-test 'lem-vi-mode/tests/text-objects::word-object)
```
18 changes: 17 additions & 1 deletion extensions/vi-mode/tests/text-objects.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,20 @@
(ok (buf= " \"foo\"< \"bar[\"]>")))
(with-vi-buffer (" \"foo\" \"bar[\"]")
(cmd "va\"")
(ok (buf= " \"foo\"< \"bar[\"]>")))))
(ok (buf= " \"foo\"< \"bar[\"]>")))

;; Escape Character
; v i
(with-vi-buffer (" \" f[o]o \\\" bar \"")
(cmd "vi\"")
(ok (buf= " \"< foo \\\" bar[ ]>\"")))
(with-vi-buffer (" \" foo \\\" b[a]r \"")
(cmd "vi\"")
(ok (buf= " \"< foo \\\" bar[ ]>\"")))
; v a
(with-vi-buffer (" \" f[o]o \\\" bar \"")
(cmd "va\"")
(ok (buf= " <\" foo \\\" bar [\"]>")))
(with-vi-buffer (" \" foo \\\" b[a]r \"")
(cmd "va\"")
(ok (buf= " <\" foo \\\" bar [\"]>")))))
20 changes: 14 additions & 6 deletions extensions/vi-mode/text-objects.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,14 @@
;; No quote-char found
((null prev-char)
(keyboard-quit))
;; Skip escaped quote-char
((and escape-char
(char= prev-char escape-char)))
;; Successfully found

;; Skip escape & quote-char
((and escape-char
(character-at point -2) ;; Bound check
(char= (character-at point -2) escape-char))
(character-offset point -2))

;; Successfully found unescaped quote
(t
(character-offset point -1)
(return))))))
Expand All @@ -304,9 +308,13 @@
;; No quote-char found
((null next-char)
(keyboard-quit))
;; Skip escaped quote-char

;; Skip escape & quote-char
((and escape-char
(char= (character-at point -1) escape-char)))
(character-at point 2) ;; Bound Check
(char= (character-at point -1) escape-char))
(character-offset point 2))

;; Successfully found
(t
(character-offset point 1)
Expand Down
Loading