Should micro set $PWD in CdCmd()/cd?
Los mantenedores suelen responder en 3 días
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 48/100
Línea de trabajo
Start with CdCmd() in internal/action/command.go around the os.Getwd() call cited in the issue, then check how buffer paths are updated and look for tests covering cd and working directory behavior. Confirm how PWD should be managed on Unix and how other platforms should behave; done means cd preserves logical paths as intended without breaking buffer paths or cross platform behavior.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
Description
Hi, lovely micro maintainers! Thank you all for maintaining a nice and, so far, AI-free, editor shell. Hope you don't mind a feature request.
Could CdCmd()/cd please set and manage the PWD environment variable so that it appears to work with logical paths on Unix platforms? It would seem less surprising, since >open stores the logical path in buffers' AbsPath fields. Setting this var permutes how subsequent calls to os.Getwd() work, and therefore how tabs display, into something that's arguably nicer for the user when symbolic links are involved.
By "logical path", I mean the path as specified on the command line, or to >cd, >open, etc. in an editor session. On Unix, this can contain unresolved symlinks. Let's call the opposite the "real path", after the Unix realpath command which resolves all symlinks (cf. Go's filepath.EvalSymlinks()).
Backstory
I've recently been making an autocd plugin that automatically >cds you around if you're working on multiple projects, in the way I was using vim-rooter and similar personal code in neovim. One of the design choices for this plugin is that I want to work pretty much exclusively with logical paths - i.e. using the paths I choose, before symlinks are resolved. I'm a heavy user of GNU stow on Unix platforms, and some of my projects are hidden behind its managed symlinks.
It's easy to process buffer paths without resolving symlinks in Micro because its buffers' AbsPath fields store the logical paths. However, the automated >cd commands appeared to be resolving symlinks unnecessarily. It turns out that's just the way the underlying Go funcs work, and Micro's CdCmd() uses os.Getwd()'s stock behaviour to rejiggle the relative Path fields on buffers. OK.
Knowing that, I was able to get the desired behaviour by setting the PWD environment variable just before calling bp:CdCmd(). This is documented Golang behaviour for its os.Getwd().
On Unix platforms, if the environment variable PWD provides an absolute name, and it is a name of the current directory, it is returned.
Suggestion: manage PWD in micro
Anyway, at the end of that long ramble, I'm left wondering why micro-editor doesn't manage this variable itself on Unix platforms, like bash and other shells do, so that all Getwd()/pwd commands produce logical paths. I think it would be less surprising to users, since buffer paths (and therefore default tab display strings) are stored as, and display using, logical paths.
Maybe the PWD setting should go just before CdCmd() calls os.Getwd(), so that the value of wd is a logical path? If that was done, the re-jiggling of the Paths would work relative to what the user probably perceives as their working directory.
I'm of course working with the plugin I wrote, and so far I haven't observed any weird behaviour by doing this in the plugin.
Environment
- Version: 2.0.15
- OS: Debian testing
- Terminal: alacritty
- Lenguaje dominante
- Go
- Estrellas
- 29.8k
- Forks
- 1.4k
- Merge medio
- 1 d 12 h
- PR fusionados (30 d)
- 2
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de micro-editor/micro
-
feature syntax
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
micro-editor/micro#4289 ·
Los mantenedores suelen responder en 3 días
-
Also bind alt-click for multi-cursorsPosiblemente ocupada Un pull request vinculado a esta issue está abierto o ya se fusionó. Abiertofeature
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
micro-editor/micro#4260 ·
Los mantenedores suelen responder en 3 días
-
XML syntax highlighting breaks if empty tag contains whitespace before closePosiblemente ocupada @justadityaraj la tomó hace 57 días. Abiertobug syntax
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
micro-editor/micro#4213 · 1 comentario ·
Los mantenedores suelen responder en 3 días
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 78/100
micro-editor/micro#3553 · 5 comentarios ·
Los mantenedores suelen responder en 3 días
-
syntax
Dificultad 2/5 1-3 horas Aptitud para principiantes 64/100
micro-editor/micro#2969 · 3 comentarios · 1 reacción ·
Los mantenedores suelen responder en 3 días
Todos los issues de micro-editor/micro
Issues similares
-
agent-butler-finding bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
jordansmall/spindrift#6414 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100
Icinga/icinga-kubernetes#294 ·
Los mantenedores suelen responder en 4 días
-
Cluster details: the Control Plane version field has a different border color than its icon boxAbiertokind/design sig/ui
Dificultad 1/5 Menos de una hora Aptitud para principiantes 92/100
kubermatic/dashboard#8449 ·
Los mantenedores suelen responder en 1 día
-
needs-triage
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
cli/cli#14962 · 1 comentario · 1 reacción ·
Los mantenedores suelen responder en 1 día
-
Model conformance driftAbiertomodel-drift
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
Los mantenedores suelen responder en 1 día