rn23thakur
8e7fbcc131
language: Fix bracket not_in scopes being ignored at end of buffer ( #64840 )
...
## Summary
"Closes #64820 "
Bracket `not_in` rules (like "don't auto-close `'` inside a comment")
were ignored when the cursor was at the very end of the file. For
example, in a C file containing only `// it ''`, typing `'` at EOF would
still auto-insert a closing `'`, even though C disables that pair inside
comments.
The cause was in `language_scope_at` in `buffer.rs`. It walks down the
syntax tree using `Range::contains`, which excludes the end of the
range. At EOF, the cursor offset equals the end of the root node, so
every layer got skipped. The function then fell back to a scope with no
`override_id`, and all `not_in` rules were lost.
The fix lets the tree walk accept the end of a node's range, but only
when the cursor is at the end of the buffer. Behavior everywhere else in
the file is unchanged. Huge thanks to @arixsnow who reported this in
#64820 with clear repro steps and tracked the root cause. This PR
implements the fix they pointed to.
https://github.com/user-attachments/assets/dc3680c0-46f1-4fc1-b80a-973f18398139
## Testing
Ran `cargo test -p language`, all passed.
The issue #64820 includes directions to reproduce it clearly I used the
same to test the fix.
## Self-review
- [x] I've reviewed my diff for quality, security, reliability, and
performance.
- [x] UI changes follow the
[checklist](https://zed.dev/docs/development/ui-checklist ).
- [x] Tests cover the new or changed behavior.
Release Notes:
- Fixed auto-closing brackets being inserted inside comments or strings
at the end of a file.
---------
Co-authored-by: Piotr Osiewicz <24362066+osiewicz@users.noreply.github.com >
2026-09-30 20:34:35 +00:00
..
2026-09-30 13:05:18 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-30 08:42:44 +00:00
2026-09-30 14:31:57 +00:00
2026-09-28 16:16:26 +00:00
2026-09-17 08:49:31 +00:00
2026-09-30 13:05:18 +00:00
2026-09-17 08:49:31 +00:00
2026-09-23 01:32:37 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 08:56:15 +00:00
2026-09-30 12:03:51 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 13:02:30 +00:00
2026-09-27 17:37:29 +00:00
2026-09-17 08:49:31 +00:00
2026-09-23 16:13:31 +00:00
2026-09-29 10:23:00 +00:00
2026-09-29 10:23:00 +00:00
2026-09-17 08:49:31 +00:00
2026-09-21 17:57:36 +00:00
2026-09-17 08:49:31 +00:00
2026-09-27 19:37:50 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-27 16:19:10 +00:00
2026-09-21 13:08:53 +00:00
2026-09-25 17:08:34 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 08:56:15 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-21 22:05:47 +00:00
2026-09-27 17:37:29 +00:00
2026-09-24 13:01:08 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-21 13:08:53 +00:00
2026-09-30 19:11:02 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-30 08:42:44 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-30 16:04:16 +00:00
2026-09-23 20:50:24 +00:00
2026-09-30 16:04:16 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-30 17:39:08 +00:00
2026-09-18 10:40:43 +00:00
2026-09-30 17:39:08 +00:00
2026-09-30 17:39:08 +00:00
2026-09-17 08:49:31 +00:00
2026-09-27 19:37:50 +00:00
2026-09-21 11:17:46 +00:00
2026-09-28 09:19:01 +00:00
2026-09-30 16:30:43 +00:00
2026-09-23 16:14:14 +00:00
2026-09-28 16:17:17 +00:00
2026-09-24 12:15:10 +00:00
2026-09-28 16:17:17 +00:00
2026-09-28 16:17:17 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-21 02:25:54 +00:00
2026-09-28 15:58:47 +00:00
2026-09-28 16:17:17 +00:00
2026-09-29 22:35:25 +00:00
2026-09-17 08:49:31 +00:00
2026-09-29 20:19:48 +00:00
2026-09-17 08:49:31 +00:00
2026-09-29 09:20:46 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-23 03:59:20 +00:00
2026-09-30 20:34:35 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 21:53:02 +00:00
2026-09-25 20:05:45 +00:00
2026-09-25 17:08:34 +00:00
2026-09-30 13:58:23 +00:00
2026-09-28 19:11:12 +00:00
2026-09-17 08:49:31 +00:00
2026-09-23 16:15:20 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-27 16:19:10 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-30 05:24:40 +00:00
2026-09-23 03:58:52 +00:00
2026-09-17 08:49:31 +00:00
2026-09-21 15:15:54 +00:00
2026-09-17 08:49:31 +00:00
2026-09-22 11:01:26 +00:00
2026-09-23 16:13:31 +00:00
2026-09-30 04:51:51 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-30 13:58:23 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-25 17:08:34 +00:00
2026-09-23 13:15:09 +00:00
2026-09-25 07:50:32 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-24 14:20:14 +00:00
2026-09-30 18:35:02 +00:00
2026-09-27 16:19:10 +00:00
2026-09-28 08:56:15 +00:00
2026-09-17 08:49:31 +00:00
2026-09-29 13:38:22 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-26 11:49:59 +00:00
2026-09-17 08:49:31 +00:00
2026-09-29 13:38:22 +00:00
2026-09-23 08:54:29 +00:00
2026-09-17 08:49:31 +00:00
2026-09-27 17:37:29 +00:00
2026-09-17 08:49:31 +00:00
2026-09-18 10:50:41 +00:00
2026-09-24 09:52:26 +00:00
2026-09-28 07:16:22 +00:00
2026-09-28 16:16:26 +00:00
2026-09-21 13:08:53 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 16:16:26 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 16:16:26 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-27 17:37:29 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 12:57:01 +00:00
2026-09-19 01:57:44 +00:00
2026-09-19 01:57:44 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-30 13:05:18 +00:00
2026-09-30 13:05:18 +00:00
2026-09-28 15:53:53 +00:00
2026-09-28 06:14:04 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 09:30:00 +00:00
2026-09-17 08:49:31 +00:00
2026-09-30 12:03:51 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 08:56:15 +00:00
2026-09-17 08:49:31 +00:00
2026-09-28 15:53:53 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-29 14:47:49 +00:00
2026-09-29 21:40:48 +00:00
2026-09-24 14:20:14 +00:00
2026-09-30 18:35:02 +00:00
2026-09-22 14:29:32 +00:00
2026-09-25 17:08:34 +00:00
2026-09-30 16:03:44 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00
2026-09-17 08:49:31 +00:00