Skip to content

Incorrect swap_previous behavior with Rust code #889

Description

@adaszko

Describe the bug
swap_previous on Rust snippet results in malformed syntax

To Reproduce
Steps to reproduce the behavior:

  1. Place the cursor on test parameter:
fn main() {
    if let Some(foo) = bar(baz, test, 100) {
                             // ^ here
    }
}
  1. Issue swap_previous
  2. Results in:
fn main() {
    if let , test(foo) = bar(bazSome, 100) {
    }
}

Expected behavior

fn main() {
    if let Some(foo) = bar(test, baz, 100) {
    }
}

Output of :checkhealth nvim-treesitter

Details

Paste the output here

Output of nvim --version

==============================================================================
nvim-treesitter:                                                            ✅

Requirements ~
- ✅ OK Neovim was compiled with tree-sitter runtime ABI version 15 (required >=13).
- ✅ OK tree-sitter-cli 0.26.8 (/opt/homebrew/bin/tree-sitter)
- ✅ OK tar 3.5.3 (/usr/bin/tar)
- ✅ OK curl 8.7.1 (/usr/bin/curl)
  curl 8.7.1 (x86_64-apple-darwin25.0) libcurl/8.7.1 (SecureTransport) LibreSSL/3.3.6 zlib/1.2.12 nghttp2/1.68.1
  Release-Date: 2024-03-27
  Protocols: dict file ftp ftps gopher gophers http https imap imaps ipfs ipns ldap ldaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
  Features: alt-svc AsynchDNS GSS-API HSTS HTTP2 HTTPS-proxy IPv6 Kerberos Largefile libz MultiSSL NTLM SPNEGO SSL threadsafe UnixSockets

OS Info ~
- machine: arm64
- sysname: Darwin
- release: 25.5.0
- version: Darwin Kernel Version 25.5.0: Mon Apr 27 20:38:56 PDT 2026; root:xnu-12377.121.6~2/RELEASE_ARM64_T6000

Install directory for parsers and queries ~
- /Users/adaszko/.local/share/nvim/site
- ✅ OK is writable.
- ✅ OK is in runtimepath.

Installed languages     H L F I J ~
- ecma
- go                    ✓ ✓ ✓ ✓ ✓
- javascript            ✓ ✓ ✓ ✓ ✓
- jsx
- markdown              ✓ . ✓ ✓ ✓
- markdown_inline       ✓ . . . ✓
- python                ✓ ✓ ✓ ✓ ✓
- rust                  ✓ ✓ ✓ ✓ ✓
- zig                   ✓ ✓ ✓ ✓ ✓

  Legend: [H]ighlights, [L]ocals, [F]olds, [I]ndents, In[J]ections ~

Additional context
Add any other context about the problem here.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions