micro-editor / micro-editor/micro
PATCH: Micro puts state information in config directory
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
I posted this patch in a different issue a few weeks ago but it doesn't look like anyone saw it there so I figured I should create a new issue for it.
This patch fixes a problem reported in multiple issues (at least #3185, #3176 and #2004).
Micro puts state data in its configuration directory instead of a separate state data directory. This state data can grow very large which makes copying micro configuration to a new computer over a slow link much slower than expected. Since this state data can also include text, history and other information from previous files edited this could lead to an inadvertent disclosure of private or confidential information if the config directory is copied to a system where other people have access.
This patch separates micro's state files from micro's config files. With this patch state information is now stored in $MICRO_STATE_HOME so for example files that were previously searched for in $MICRO_CONFIG_HOME/buffers or $MICRO_CONFIG_HOME/backups are now searched for in $MICRO_STATE_HOME/buffers or $MICRO_STATE_HOME/backups respectively. If $MICRO_STATE_HOME does not exist $XDG_STATE_HOME/micro/ is used instead. If that doesn't exist either $HOME/.local/state/micro/ is used.
This patch simply adds a config.StateDir variable (alongside the existing config.ConfigDir) and uses it for state stuff. The patch will create the state directories if they don't already exist but does not touch the old location.
I don't do anything for migration because IMO it's not worth adding code that will sit in micro forever to address the minor one-time slight annoyance of history and cursor positions being reset. I think a small external migration script would be better for that (not included).
If anyone would like to test this without the hassle of building micro from source a statically linked binary for 64-bit Linux (x86_64) can be found here. It should work on any x86_64 Linux distribution. A statically linked binary for 64-bit Arm Linux (aarch64) can be found here for those of you using 64 bit ARM servers or Pis.
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
Start by reading the attached micro_state_dir.patch.txt and locate the existing config.ConfigDir handling and state paths for buffers and backups. Check how MICRO_STATE_HOME, XDG_STATE_HOME, and HOME are resolved, then build and test micro across the supported path cases. Done means state files use the separate state directory without changing the old location.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100