Some commands exist but appear unavailable
Closed this issue · 20 comments
@likemuuxi Thanks for the bug report!
- Can you please provide more detailed steps of how you added this item?
- Is that the Toggle Blockquote command or something different?
- What language specifically are you using Obsidian in?
@Moyf if you have a moment, are you able to replicate this bug?
At least on macOS if I change my language, and copy/paste "引用", I am able to select the command no problem.
@likemuuxi Thanks for the bug report!
- 你能提供更多关于如何添加此项目的详细步骤吗?
- 这是“切换块引用”命令还是其他命令?
- 你使用黑曜石语的具体语言是什么?
@Moyf if you have a moment, are you able to replicate this bug?
At least on macOS I changed my language, and entered 引用 and am able to select the command no problem.
Oh.. On my PC (Windows) with Chinese language, I can replicate this issue 🤔
The "引用" means "Toggle Quote" AKA this command:
I tried the English command, it works:
So strange.. I guess it could be due to OB's localization?
@likemuuxi Thank you for the video! It was super helpful to see what you were typing. Once I was able to turn on Chinese input I was able to reproduce as well. @Moyf Thank you for confirming, and for the explanation as well!
I will investigate when I get a chance.
@likemuuxi Thank you for the video! It was super helpful to see what you were typing. Once I was able to turn on Chinese input I was able to reproduce as well. @Moyf Thank you for confirming, and for the explanation as well!
I will investigate when I get a chance.
You even specifically switched to Chinese input, so enthusiastic!
(But just a quick note, you should have typed yin'yong
: 引用
@Moyf Haha, thanks. Tried it again with yin'yong
and got the same result, fortunately for me. 👍
@Moyf Actually, I wasn't looking close enough at the characters. 🤦♂️
This actually does work for me:
I thought it had to do with the onchange()
being triggered and saved (as Pinyin) before the Chinese characters were replaced. But I put in some debug statements and it looks like it is saving it correctly, with the Chinese characters. (Again, on macOS.)
Now I'm stumped again, and hoping it's not a Windows-only bug.
@Moyf Can you record what you did?
I thought it had to do with the
onchange()
being triggered and saved (as Pinyin) before the Chinese characters were replaced. But I put in some debug statements and it looks like it is saving it correctly, with the Chinese characters. (Again, on macOS.)Now I'm stumped again, and hoping it's not a Windows-only bug.
@Moyf Can you record what you did?
I did some tests:
I tried "保存当前文件" (Save Current File), and delete one character, the warning appears.
After I choose the item in auto-suggestion, the warning stays for a while and disappears.
(It was refreshed in some way?)
[2] I tried to just Paste the word "引用" - it should have nothing related to IME (PinYin) - and still warns.
[3] I use `app.commands to see the command itself:
Its name is "引用"- precisely same word!!
So I'm also confused now.. I'll try it on my mac later.
Just tested in my macOS (Sequoia 15.1) / Obsidian 1.7.4, it's same with the gif in [2]
So strange.. I'm afraid it might be some issues inside the Obsidian.
I also checked the Localization file in this page, line 568, it seems everything is OK.
Which is even stranger is that, as you can see, I tried another command "Shell commands: Execute: 引用记号附链接" - this should be more complex but it works 😂
So for @likemuuxi I got 2 suggestions based on this weird situation:
- Switching to English language in Obsidian 😏
- Use plugin like Commander to warp the origin "引用" command as a new command, and bind this new command
@chrisgurney Could you show me the code how do you find the command by name?
BTW, @likemuuxi actually the English name is also available in Chinese Language OB:
So maybe just use Toggle blockquote
rather than 引用
? Just as a temp fix :P
@Moyf Here's the CommandSuggester, which displays the command options:
The code that highlights the field if there's a problem is here:
First thought: I think I should be using this when lower-casing strings, and I'm not, but I don't think that's contributing to the issue here:
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/toLocaleLowerCase
Thank you for taking a look!
刚刚在我的macOS(Sequoia 15.1)/Obsidian 1.7.4中进行了测试,它与[2]中的gif相同
真奇怪。。恐怕黑曜石内部有些问题。
我还检查了本页第568行的本地化文件,似乎一切正常。
更奇怪的是,正如你所看到的,我尝试了另一个命令“Shell commands:Execute:引用编号附件”-这应该更复杂,但它有效😂
因此,对于@likemuuxi,基于这种奇怪的情况,我有两个建议:
- 在黑曜石语中切换到英语😏
- 使用类似Commander的插件将原始“引用”命令扭曲为新命令,并绑定此新命令
@Moyf Thanks for the suggestion, but in my tests this problem occurred not only with 引用
/Toggle blockquote
to this command, but also with other commands like 代码块
/Toggle code
. There are many other commands that behave this way, and they are all internal Obsidian commands.
@chrisgurney One thing worth notice is that the information I imported from the share command was available, and only showed this when I added it myself.
I made a small change in the latest beta that may help, but I'm doubtful: I changed contains()
→ includes()
, though I suspect the former was just an alias for the latter.
Can somebody please try to reproduce the issue again?
@likemuuxi OK thanks for checking.
I don't know why, but only the editor: toggle blockquote
and editor: insert code block
commands were selected and not added to the commandId
key in data.json
. However, console.log("Available commands:", Object.keys((this.app as any).commands.commands));
The command does exist, I think we can add debugging information to confirm what exactly happened.
@likemuuxi @Moyf OK I have a fix in the latest beta.
I'm not sure what the cause was in the end, but I changed how the command ID is updated from the CommandSuggester field, which I think I was doing incorrectly and was being overridden by Obsidian somehow. I was able to duplicate the issue, and test the fix, with the Insert code block (代码块) command.
Please let me know if this works for you @likemuuxi!
@chrisgurney That's great! There is no such problem now.🎉