diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..d1c9f6b19 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,13 @@ +# Set default behavior to automatically normalize line endings. +* text=auto + +# Force batch scripts to always use CRLF line endings so that if a repo is accessed +# in Windows via a file share from Linux, the scripts will work. +*.{cmd,[cC][mM][dD]} text working-tree-encoding=UTF-16LE eol=CRLF +*.{bat,[bB][aA][tT]} text working-tree-encoding=UTF-16LE eol=CRLF +*.{ics,[iI][cC][sS]} text working-tree-encoding=UTF-16LE eol=CRLF +*.{ps1,[iP][sS][1]} text working-tree-encoding=UTF-16LE eol=CRLF + +# Force bash scripts to always use LF line endings so that if a repo is accessed +# in Unix via a file share from Windows, the scripts will work. +*.sh text eol=lfol=lf diff --git a/public/kcl-samples-manifest-fallback.json b/public/kcl-samples-manifest-fallback.json index 5879f59de..15fa527df 100644 --- a/public/kcl-samples-manifest-fallback.json +++ b/public/kcl-samples-manifest-fallback.json @@ -34,6 +34,13 @@ "title": "Car Wheel Assembly", "description": "A car wheel assembly with a rotor, tire, and lug nuts." }, + { + "file": "main.kcl", + "pathFromProjectDirectoryToFirstFile": "color-cube/main.kcl", + "multipleFiles": false, + "title": "Color Cube", + "description": "This is a color cube centered about the origin. It is used to help determine orientation in the scene." + }, { "file": "main.kcl", "pathFromProjectDirectoryToFirstFile": "cycloidal-gear/main.kcl", diff --git a/src/components/Settings/AllSettingsFields.tsx b/src/components/Settings/AllSettingsFields.tsx index 4251ef803..6a1fa7644 100644 --- a/src/components/Settings/AllSettingsFields.tsx +++ b/src/components/Settings/AllSettingsFields.tsx @@ -20,7 +20,7 @@ import { getSettingsFolderPaths, } from 'lib/desktopFS' import { useDotDotSlash } from 'hooks/useDotDotSlash' -import { ForwardedRef, forwardRef, useEffect } from 'react' +import { ForwardedRef, forwardRef, useEffect, useMemo } from 'react' import { useLspContext } from 'components/LspProvider' import { toSync } from 'lib/utils' import { reportRejection } from 'lib/trap' @@ -44,20 +44,22 @@ export const AllSettingsFields = forwardRef( settings: { send, context, state }, } = useSettingsAuthContext() - const projectPath = - isFileSettings && isDesktop() - ? decodeURI( - location.pathname - .replace(PATHS.FILE + window.electron.sep, '') - .replace(PATHS.SETTINGS, '') - .slice( - 0, - decodeURI(location.pathname).lastIndexOf( - window.electron.path.sep - ) - ) - ) - : undefined + const projectPath = useMemo(() => { + const filteredPathname = location.pathname + .replace(PATHS.FILE, '') + .replace(PATHS.SETTINGS, '') + const lastSlashIndex = filteredPathname.lastIndexOf( + // This is slicing off any remaining browser path segments, + // so we don't use window.electron.sep here + '/' + ) + const projectPath = + isFileSettings && isDesktop() + ? decodeURIComponent(filteredPathname.slice(lastSlashIndex + 1)) + : undefined + + return projectPath + }, [location.pathname]) function restartOnboarding() { send({ @@ -197,9 +199,7 @@ export const AllSettingsFields = forwardRef( { - const paths = await getSettingsFolderPaths( - projectPath ? decodeURIComponent(projectPath) : undefined - ) + const paths = await getSettingsFolderPaths(projectPath) const finalPath = paths[searchParamTab] if (!finalPath) { return new Error('finalPath undefined')