micro-editor / micro-editor/micro
Micro can get confused by a shebang
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
On a fresh install of micro 2.0.2 (with only the default plugin installed), open a python script (Using a proper file extension such as *.py, *.py2 or *.py3) and with the following shebang:
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
Half of the time, the buffer is properly initialized (filetype set properly, options available through Buf.Settings[name]).
And half of the time, the buffer is not properly initialized. The most obvious way to see it is that the filetype is set to '' (empty) in the status bar. If you have a plugin that query the buffer setting:
panel.Buf.Settings[option]
it will return the global setting instead of the filetype option. it seems none of the options for the filetype in settings.json are loaded. So it makes it challenging to write plugin that is language specific (for example a plugin that should only run when a specific language is in the buffer.
Removing the shebang in the script, makes micro behave properly 100% of the time (I am guessing when there are no shebang, micro relies on the the file extension).
I experienced the problem on:
Commit hash: c51f849
OS: Ubuntu 19.10
Terminal: Gnome Terminal
Commit hash: c51f849
OS: Manjaro with Gnome 3.34.4
Terminal: Gnome Terminal
Commit hash: c51f849
OS: Android/Termux App
Terminal: Termux
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Reproduce the issue with the Python script and shebang shown in the report on the affected micro version and compare behavior with and without the shebang. Trace the filetype initialization and shebang handling, then verify that Python filetype settings and Buf.Settings values are consistent across repeated opens.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100