extensions icon indicating copy to clipboard operation
extensions copied to clipboard

System will emit a NSBeep sound when `getSelectedText()` report error.

Open koinzhang opened this issue 3 years ago • 3 comments

When the extension calls Raycast's getSelectedText() Api and uses try-catch to catch the error, the system will emit a NSBeep sound if it cannot get the selected text from the foremost app

Raycast version: 1.33.2

Description

Steps To Reproduce

export const fetchItemInput = async () => {
  try {
    await getSelectedText();
  } catch (e) {
    console.error(String(e));
  }
};
  1. Implement and call the above function in the extension.
  2. When there is no window on the desktop, open the extension and call the above function, the system will emit NSBeep sound.
  3. The actual trigger for this bug is that the selected text cannot be retrieved from the top window. That is, when getSelectedText() reports an error, it makes a sound. The following errors were caught: Error: Cannot copy selected text from frontmost application.

Another very similar api,getSelectedItem, does not make a sound when an error is reported

The current behavior

System will emit a NSBeep sound when getSelectedText() report error.

The expected behavior

System will not emit a NSBeep sound when getSelectedText() report error.

koinzhang avatar Apr 25 '22 13:04 koinzhang

Is this fixed?

mathieudutour avatar Oct 25 '22 09:10 mathieudutour

Hi @mathieudutour 👋 I just tested it and found no fix, but I couldn't see Raycast's idea of fixing it for a long time, and the bug didn't affect the actual use, so I chose to close it

koinzhang avatar Oct 25 '22 09:10 koinzhang

we do want to fix it, we didn't get to it yet. I'll reopen it

mathieudutour avatar Oct 25 '22 09:10 mathieudutour