# editor: Treat single punctuation as a word boundary \(\#58882\) · gitcafe/zed

[View on GitCafe](https://git.cafe/gitcafe/zed/commit/482963d5e9666ac52d99e98ee91a220d7bc24748)

Repository: [gitcafe/zed](https://git.cafe/gitcafe/zed)

Visibility: public

Requested revision: 482963d5e9666ac52d99e98ee91a220d7bc24748

Requested commit: 482963d5e9666ac52d99e98ee91a220d7bc24748

Commit: 482963d5e9666ac52d99e98ee91a220d7bc24748

Tree: 7069cd3f529332707f80b824a3e8c75907d287f0

Author: Maja Backman

Committer: GitHub

## Message

```
editor: Treat single punctuation as a word boundary (#58882)

## Context

`next_word_end` and `previous_word_start` have a special case that skips
a punctuation character so that word movement treats the punctuation as
a part of the word (`|.foo` -> `.foo|`). But the check only looked at
whether the next char was punctuation, not whitespace, so it skipped
single punctuation marks.

	foo |. bar -> foo . bar| (should be `foo .| bar`)

Fix: only skip the punctuation when it's next to a word char.

Closes #55601

## How to Review

In any buffer, type `foo . bar`:

- Cursor before `.`, alt-right -> stops after the `.` (`foo .| bar`),
not at the end of `bar`.
- Cursor after `.`, alt-left -> stops before the `.` (`foo |. bar`).

##  Self-Review Checklist

- [x] I've reviewed my own diff for quality, security, and reliability
- [x] Unsafe blocks (if any) have justifying comments
- [x] The content adheres to Zed's UI standards
([UX/UI](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist)
and
[icon](https://github.com/zed-industries/zed/blob/main/crates/icons/README.md)
guidelines)
- [x] Tests cover the new/changed behavior
- [x] Performance impact has been considered and is acceptable

Release Notes:

- Fixed word movement skipping single punctuation characters surrounded
by whitespace.

---------

Co-authored-by: Martin Ye <martin@zed.dev>
Co-authored-by: MartinYe1234 <52641447+MartinYe1234@users.noreply.github.com>
```

## Parents

- [ac44e9f5df57a9e1a9d6deacddead974edabc8e7](https://git.cafe/gitcafe/zed/commit/ac44e9f5df57a9e1a9d6deacddead974edabc8e7?format=markdown)

[Source at this commit](https://git.cafe/gitcafe/zed/tree/482963d5e9666ac52d99e98ee91a220d7bc24748?format=markdown)
