chrisgurney/obsidian-note-toolbar

Some commands exist but appear unavailable

Closed this issue · 20 comments

Description of the bug

some commands exist but appear not exit

Screenshots (if you think it will help)
Video or a GIF would be appreciated.

image
image

Desktop environment:

  • OS: Windows
  • Obsidian version: 1.7.4
  • Note Toolbar version: 1.14.9

@likemuuxi Thanks for the bug report!

  1. Can you please provide more detailed steps of how you added this item?
  2. Is that the Toggle Blockquote command or something different?
  3. 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.

CleanShot 2024-10-22 at 06 53 45@2x

@likemuuxi Thanks for the bug report!

  1. 你能提供更多关于如何添加此项目的详细步骤吗?
  2. 这是“切换块引用”命令还是其他命令?
  3. 你使用黑曜石语的具体语言是什么?
  1. Here are my adding steps
    1729601340455-1729599406066-20241022_201257
  2. This command is called Toggle blockquote in English
  3. My language is Chinese
Moyf commented

@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.

CleanShot 2024-10-22 at 06 53 45@2x

image

Oh.. On my PC (Windows) with Chinese language, I can replicate this issue 🤔

The "引用" means "Toggle Quote" AKA this command:
3e86bea1-4fd1-42c2-bace-ada88dd3507f

I tried the English command, it works:
image

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!

CleanShot 2024-10-22 at 10 55 29

I will investigate when I get a chance.

Moyf commented

@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!

CleanShot 2024-10-22 at 10 55 29 CleanShot 2024-10-22 at 10 55 29

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:

CleanShot 2024-10-23 at 08 11 28

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?

Moyf commented

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:

[1] Other Chinese Command:
4ec86b0b-f3dc-4346-a1e7-f97443a0fbda

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.
2e1cf8f5-e914-46fc-8fbf-df95524e5849

[3] I use `app.commands to see the command itself:
image

Its name is "引用"- precisely same word!!
So I'm also confused now.. I'll try it on my mac later.

Moyf commented

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 😂
image


So for @likemuuxi I got 2 suggestions based on this weird situation:

  1. Switching to English language in Obsidian 😏
  2. Use plugin like Commander to warp the origin "引用" command as a new command, and bind this new command

image

Moyf commented

@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:
image

So maybe just use Toggle blockquote rather than 引用? Just as a temp fix :P

@Moyf Here's the CommandSuggester, which displays the command options:

https://github.com/chrisgurney/obsidian-note-toolbar/blob/master/src/Settings/UI/Suggesters/CommandSuggester.ts

The code that highlights the field if there's a problem is here:

https://github.com/chrisgurney/obsidian-note-toolbar/blob/master/src/Settings/UI/Modals/ToolbarSettingsModal.ts#L1211

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:引用编号附件”-这应该更复杂,但它有效😂 image

因此,对于@likemuuxi,基于这种奇怪的情况,我有两个建议:

  1. 在黑曜石语中切换到英语😏
  2. 使用类似Commander的插件将原始“引用”命令扭曲为新命令,并绑定此新命令

image

@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?

20241104_211554

In the beta version, the same issue still persists

@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.🎉