Skip to content

Commit fa9724b

Browse files
committed
Refine multi-root workspace detection using workspace folders count
- in a multi root folder workspace the changes symbol is placed invalid if some root folders are not git repos[Pasted text] - Fix replace-git-symbols.ts to properly support branch names containing slashes in single-root workspaces by checking if the workspace has multiple roots before relying solely on the folder/branch regex match. └── apps └── editor └── src ├── i18n │ └── translations │ └── views │ └── prompt │ └── utils │ └── symbols │ └── git │ └── replace-git-symbols.ts ├── utils │ ├── git-repository-utils.ts │ └── is-valid-git-branch-name.ts └── views ├── prompt │ └── backend │ ├── message-handlers │ │ └── handle-preview-changes-symbol.ts │ └── utils │ └── symbols │ ├── git │ │ └── replace-git-symbols.ts │ └── replace-symbols.ts └── shared └── utils └── hash-sign-quick-pick ├── hash-sign-quick-pick.ts └── symbols └── changes-symbol.ts
1 parent 7a498ca commit fa9724b

2 files changed

Lines changed: 7 additions & 3 deletions

File tree

‎apps/editor/src/views/prompt/backend/utils/symbols/git/replace-git-symbols.ts‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,11 @@ export const replace_changes_symbol = async (params: {
158158
continue
159159
}
160160

161-
const multi_root_match = branch_spec.match(/^([^/]+)\/(.+)$/)
161+
const is_multi_root_workspace =
162+
(vscode.workspace.workspaceFolders?.length ?? 0) > 1
163+
const multi_root_match = is_multi_root_workspace
164+
? branch_spec.match(/^([^/]+)\/(.+)$/)
165+
: null
162166

163167
if (multi_root_match) {
164168
const [, folder_name, branch_name] = multi_root_match

‎apps/editor/src/views/shared/utils/hash-sign-quick-pick/symbols/changes-symbol.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export const handle_changes_item = async (
166166

167167
const cwd = selected_workspace.folder.uri.fsPath
168168
const folder_name = selected_workspace.folder.name
169-
const is_multi_root = workspace_with_branches.length > 1
169+
const is_multi_root = workspace_folders.length > 1
170170

171171
let is_active = true
172172

@@ -291,7 +291,7 @@ export const handle_changes_item = async (
291291
}
292292

293293
const formatted_branch =
294-
workspace_with_branches.length > 1
294+
workspace_folders.length > 1
295295
? `${selected_workspace.folder.name}/${selected_branch.label}`
296296
: selected_branch.label
297297

0 commit comments

Comments
 (0)