Should micro set $PWD in CdCmd()/cd?
メンテナーはふだん 3 日以内に返信
まだ誰も着手していません。
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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
- 主要言語
- Go
- スター
- 29.8k
- フォーク
- 1.4k
- 平均マージ
- 1日 12時間
- マージ済み PR(30日)
- 2
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
micro-editor/micro のほかの issue
-
feature syntax
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
micro-editor/micro#4289 ·
メンテナーはふだん 3 日以内に返信
-
Also bind alt-click for multi-cursors対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープンfeature
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
micro-editor/micro#4260 ·
メンテナーはふだん 3 日以内に返信
-
XML syntax highlighting breaks if empty tag contains whitespace before close対応中かも @justadityaraj が 58 日前に担当しました。 オープンbug syntax
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
micro-editor/micro#4213 · コメント 1 件 ·
メンテナーはふだん 3 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 78/100
micro-editor/micro#3553 · コメント 5 件 ·
メンテナーはふだん 3 日以内に返信
-
syntax
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
micro-editor/micro#2969 · コメント 3 件 · リアクション 1 件 ·
メンテナーはふだん 3 日以内に返信
micro-editor/micro の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 77/100
JakeChampion/lang#14392 ·
メンテナーはふだん 1 日以内に返信
-
agent-butler-finding bug
難易度 1/5 1〜3時間 初心者へのやさしさ 84/100
jordansmall/spindrift#6557 ·
メンテナーはふだん 1 日以内に返信
-
[Bug] Custom tool truncation leaves unused stream copies open対応中かも @OUAO-FRANK が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
メンテナーはふだん 1 日以内に返信
-
[v3] KeyBindingManager calls (Add/Remove) are not converted into a case-insensitive accelerator.KeyオープンBug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
crmne/hyprmoncfg#114 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信