Skip to content

Conversation

seflue
Copy link
Contributor

@seflue seflue commented Aug 9, 2025

Buffer lookup failed for filenames containing [], (), . and other regex metacharacters.

  • Add utils.get_buffer_by_filename() with proper Vim regex escaping
  • Replace duplicate buffer lookup patterns across files

Summary

This PR fixes buffer lookup failures when filenames contain regex special characters like [], (), ., etc. The issue occurred because vim.fn.bufnr() patterns weren't properly escaped for Vim regex syntax, causing buffer operations (todo state, links, refiling) to fail.

Related Issues

Closes #1021

Changes

  • Add utils.get_buffer_by_filename() utility function with proper Vim regex escaping using vim.fn.escape()
  • Replace 6 duplicate buffer lookup patterns across 4 files (files/file.lua, api/init.lua, api/headline.lua,
    api/file.lua)
  • Add comprehensive test coverage for special character scenarios in tests/plenary/utils_spec.lua

Checklist

I confirm that I have:

  • Followed the
    Conventional Commits
    specification
    (e.g., feat: add new feature, fix: correct bug,
    docs: update documentation).
  • My PR title also follows the conventional commits specification.
  • Updated relevant documentation, if necessary.
  • Thoroughly tested my changes.
  • Added tests (if applicable) and verified existing tests pass with
    make test.
  • Checked for breaking changes and documented them, if any.

Buffer lookup failed for filenames containing [], (), . and other regex
metacharacters.

- Add utils.get_buffer_by_filename() with proper Vim regex escaping
- Replace duplicate buffer lookup patterns across files
@seflue seflue force-pushed the fix/support-special-char-filenames branch from bd88635 to d30551d Compare August 16, 2025 14:41
Copy link
Member

@kristijanhusak kristijanhusak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@kristijanhusak kristijanhusak merged commit e16452b into nvim-orgmode:master Sep 3, 2025
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Buffer lookup fails for filenames with special regex characters

2 participants