# vim: Add C preprocessor check in matching function \(\#55515\) · gitcafe/zed

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

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

Visibility: public

Requested revision: 0bcf71f786ccf2194901ce1542fef7d9b4e2e82e

Requested commit: 0bcf71f786ccf2194901ce1542fef7d9b4e2e82e

Commit: 0bcf71f786ccf2194901ce1542fef7d9b4e2e82e

Tree: af2c28683753091aacab40f153019a4fd54079e2

Author: Juan Pablo Briones

Committer: GitHub

## Message

```
vim: Add C preprocessor check in matching function (#55515)

Closes #24820

This PR fixes the bug specified in issue
https://github.com/zed-industries/zed/issues/24820, now the matching
function checks if the cursor is above a comment or a directive before
defaulting to a bracket range as neovim does.

It also fixes fixes the `line_end` calculations so that when `%` is
pressed inside a bracket range


https://github.com/user-attachments/assets/f59daa6f-9769-45e8-bb8c-2d533470b59d

Release Notes:

- `fn matching()` checks for `preprocessor directives` or `comments`
before defaulting to any bracket range.
- In `fn matching()`line_end calculations avoid expanding a blank
current line into start..EOF.
```

## Parents

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

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