normalizeWorkspaceName function

String normalizeWorkspaceName(
  1. String value
)

Normalises a workspace name for comparison: trims whitespace, drops a trailing .code-workspace extension, and strips VS Code's " (Workspace)" multi-root suffix.

Implementation

String normalizeWorkspaceName(String value) {
  var v = value.trim();
  const ext = '.code-workspace';
  if (v.endsWith(ext)) v = v.substring(0, v.length - ext.length);
  const suffix = ' (Workspace)';
  if (v.endsWith(suffix)) v = v.substring(0, v.length - suffix.length);
  return v.trim();
}