Skip to content

comment: Key Objective-C by its real filetype - #4270

Open
xlb3055 wants to merge 1 commit into
micro-editor:masterfrom
xlb3055:fix/comment-objective-c
Open

xlb3055 wants to merge 1 commit into
micro-editor:masterfrom
xlb3055:fix/comment-objective-c

Conversation

@xlb3055

@xlb3055 xlb3055 commented Oct 19, 2026

Copy link
Copy Markdown

The comment plugin keys Objective-C as ft["objc"], but the bundled runtime/syntax/objc.yaml declares filetype: objective-c, and that is the value a buffer gets (b.Settings["filetype"] = b.SyntaxDef.FileType in internal/buffer/buffer.go). The lookup in updateCommentType() therefore never matches, and .m/.mm buffers fall back to the default # %s.

To reproduce: open a .m file, put the cursor on int x = 1; and press Alt-/. The line becomes # int x = 1; instead of // int x = 1;. A leading # is a preprocessor directive in Objective-C, so the file no longer compiles.

This renames the key to objective-c in comment.lua and in the plugin's help list, matching the other entries, which use the syntax files' filetype names (c, c++, csharp, ...).

Checked by loading the real comment.lua into gopher-lua with a stub import and calling updateCommentType() on a stub buffer:

filetype before after
objective-c # %s // %s
c // %s // %s
unknown # %s # %s

ft["python3"] and ft["conf"] don't match any bundled filetype either (Python is python), but they would fall back to # %s, which is the same value, so I left them alone.

Prepared with AI assistance (Claude Code). I did not build or run micro itself; the only local check was running the plugin function in gopher-lua as shown above, before and after the change.

🤖 Generated with Claude Code

The bundled Objective-C syntax file declares `filetype: objective-c`,
but the comment plugin keyed its comment type as `objc`. The lookup in
updateCommentType() never matched, so .m/.mm buffers fell back to the
default "# %s" and toggling a comment prefixed the line with `#`,
which Objective-C treats as a preprocessor directive.

Co-Authored-By: Claude <noreply@anthropic.com>

@Andriamanitra Andriamanitra left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Good catch, objc must have slipped in accidentally even though the filetype is called objective-c.

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.

2 participants