From cfbe93e6d0a762fe874fe33e629cb3aba4cba04e Mon Sep 17 00:00:00 2001 From: aronsysdone <110933423+aronsysdone@users.noreply.github.com> Date: Sun, 9 Aug 2026 15:49:16 -0400 Subject: [PATCH] fix: sort project files alphabetically on pull to preserve sidebar order Fixes an issue where pulling modified files from GitHub/SCM alters the file ordering in Google Apps Script. During a pull, modified files are concatenated ahead of unchanged files (`updatedFiles.concat(remainedFiles)`), placing modified items at the top of the array payload. Because Google Apps Script renders the IDE sidebar strictly based on array index position in the manifest, updated files were permanently pushed to the top of the sidebar. This change sorts the concatenated `files` array alphabetically before sending the PUT request, keeping the `appsscript` manifest at index 0. --- src/gas/script-api.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/gas/script-api.js b/src/gas/script-api.js index ef0e5d8..1a558a2 100644 --- a/src/gas/script-api.js +++ b/src/gas/script-api.js @@ -52,6 +52,11 @@ class ScriptApi { } }); const files = updatedFiles.concat(remainedFiles); + files.sort((a, b) => { + if (a.name === 'appsscript') return -1; + if (b.name === 'appsscript') return 1; + return a.name.localeCompare(b.name); + }); console.log(files) this.updateToken() @@ -174,4 +179,4 @@ class ScriptApi { }); } } -} \ No newline at end of file +}