8000 feat(completion): default command suggestions to off by yiqiui · Pull Request #474 · t8y2/motty · GitHub
[go: up one dir, main page]

Skip to content

feat(completion): default command suggestions to off - #474

Open
yiqiui wants to merge 2 commits into
t8y2:mainfrom
yiqiui:fix/303-completion-default-off
Open

yiqiui wants to merge 2 commits into
t8y2:mainfrom
yiqiui:fix/303-completion-default-off

Conversation

@yiqiui
@yiqiui yiqiui commented Nov 4, 2026
Copy link
Copy Markdown
Contributor

Summary

补全建议(列表 + 灰色内联提示)会把主机上不存在的命令也提示出来(如输入 pwd 建议 pwdx、nc 建议 ncdu),造成困惑。按 issue 诉求,把补全模式的默认值从「列表+内联」改为「关闭」;需要建议的用户在设置里打开即可。

实现上的关键点(为什么不是一行改默认值):

  • 模式原先只存在两个布尔位里,而「both」的存储形态(两个 false)与旧默认完全相同——omitempty 会把 false 丢掉,所以直接翻转默认既不会生效(restore 无条件用文件覆盖),也无法钉住用户显式选择的 both。
  • 为模式新增一个专属共享记录 command_completion(list / both,缺省 = 新默认 off)。记录存在时权威;缺失时回退到旧布尔位(老构建写的目录语义不变);两者皆无 = 从未表达过偏好 → 取新默认。
  • newState 在生成 config 默认值快照之前初始化为新默认,使「选 List/Both」成为与默认的差异而被写盘钉住,跨重启不丢。
  • 新构建继续写旧布尔位,老版本读新存档语义不变;老版本写的存档被新版本完整保留。

Behavior

  • 全新安装 / 从未设置过补全的用户:建议默认关闭(含手动补全快捷键,与现有 Off 模式语义一致)。
  • 旧版里显式选过「关闭 / 仅列表 / 列表+内联」的用户:升级后完全不变。
  • 旧版里从未改过的用户(隐式 both):升级后随新默认变为关闭;若再显式选择任何模式都会被记录钉住。
  • 设置页三档分段控件的默认选中态随新默认变化;多设备同步语义一致(新记录是共享设置)。

Test plan

  • TestEarlierCompletionPreferencesKeepTheirMeaning:旧布尔位三种记录 + 新记录三种取值 + 记录优先于旧布尔,全部按预期读取。
  • TestAChoiceAgainstTheCompletionDefaultIsPinned:全新状态=Off;显式选 Both → save → 重启后仍是 Both(钉住不丢)。
  • TestCompletionControlsAndKeysHaveSeparateSettingsHomes:设置页默认选中态 = Off(en/zh-CN 双语)。
  • ghost/补全行为套件显式开启建议后全部通过(ghostWorld / newCompletionWorld 助手固化前置条件)。
  • go build ./...、gofmt、go vet 通过;Settings/Persist/Shortcut/Record 等中范围回归全绿。

Closes #303

@yiqiui
yiqiui force-pushed the fix/303-completion-default-off branch from 73d9e26 to 7df60be Compare November 4, 2026 16:36
Closes t8y2#303

The completion mode (list, inline ghost, or both) suggested commands the
host does not have, and the reporter asked for suggestions to start off.

The mode lived only in two boolean flags whose 'both' spelling is also
the older default, so a plain default flip could neither take effect
(restore overwrites from the file) nor pin an explicit 'both' (both
false is dropped by omitempty). Give the mode its own shared record,
'command_completion', written only against the new default; it outranks
the older flags when present, the flags keep their meaning for catalogs
written by older builds, and a catalog with neither record nor flags —
a choice never expressed — takes the new default. The state the config
defaults are taken from initializes to the new default, so a reader who
picks List or Both has the choice written and pinned across restarts.

Every previously recorded choice keeps its meaning; only catalogs that
never recorded one move to the new default.
@yiqiui
yiqiui force-pushed the fix/303-completion-default-off branch from 7df60be to 91140a3 Compare November 11, 2026 16:07
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.

SSH终端命令补全建议默认关闭

1 participant

0