Skip to content

Fix inefficient AppleScript loop in Webstorm workflow#8

Open
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1767680193-fix-webstorm-applescript-efficiency
Open

Fix inefficient AppleScript loop in Webstorm workflow#8
devin-ai-integration[bot] wants to merge 1 commit intomainfrom
devin/1767680193-fix-webstorm-applescript-efficiency

Conversation

@devin-ai-integration
Copy link
Contributor

Summary

This PR optimizes the AppleScript code in the "Open with Webstorm" Alfred workflow by removing an unnecessary loop. When the Finder selection contains exactly 1 item, the previous code used a repeat loop to iterate over a single-item collection, which is redundant. The fix directly accesses item 1 of theSelection instead.

Before:

if length of theSelection is equal to 1 then
    set pathList to {}
    repeat with anItem in theSelection
        set pathList to quoted form of POSIX path of (anItem as text)
    end repeat

After:

if length of theSelection is equal to 1 then
    set pathList to quoted form of POSIX path of (item 1 of theSelection as text)

Review & Testing Checklist for Human

  • Extract and verify the change: Since .alfredworkflow is a binary zip file, extract it (unzip "Open with Webstorm.alfredworkflow") and verify the info.plist contains the expected AppleScript change
  • Test with single file selected: In Finder, select a single file/folder and trigger the workflow - verify it opens in WebStorm correctly
  • Test with no selection: With no file selected in Finder, trigger the workflow - verify it falls back to opening the current folder

Recommended test plan: Install the updated workflow in Alfred on macOS and test both scenarios (single selection and no selection) to confirm the workflow behaves identically to before.

Notes

An efficiency report documenting additional potential improvements was created but not committed to the repo (available in the session).

Link to Devin run: https://app.devin.ai/sessions/86e2ebeee5df4399a9115e8f3a13d955
Requested by: wang qiwei (kiwei666888@gmail.com) / @qiwei66

- Remove unnecessary repeat loop when selection length is 1
- Remove redundant pathList initialization to empty list
- Directly access item 1 of selection instead of looping

Co-Authored-By: wang qiwei <davidmaeew@gmail.com>
@devin-ai-integration
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

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.

0 participants

Comments