[bugfix] Fix user settings opening (#5414)

* Create .gitattributes

* Fix projectPath URI decoding

* Try to enforce UTF-8 encoding on all files except Windows-specific
scripts

* edit file encoding

* edit gitattributes

* Update kcl-samples

* fmt
This commit is contained in:
Frank Noirot
2025-02-19 13:31:07 -05:00
committed by GitHub
parent c050e03df1
commit b98f5605b6
3 changed files with 38 additions and 18 deletions

13
.gitattributes vendored Normal file
View File

@ -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

View File

@ -34,6 +34,13 @@
"title": "Car Wheel Assembly", "title": "Car Wheel Assembly",
"description": "A car wheel assembly with a rotor, tire, and lug nuts." "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", "file": "main.kcl",
"pathFromProjectDirectoryToFirstFile": "cycloidal-gear/main.kcl", "pathFromProjectDirectoryToFirstFile": "cycloidal-gear/main.kcl",

View File

@ -20,7 +20,7 @@ import {
getSettingsFolderPaths, getSettingsFolderPaths,
} from 'lib/desktopFS' } from 'lib/desktopFS'
import { useDotDotSlash } from 'hooks/useDotDotSlash' import { useDotDotSlash } from 'hooks/useDotDotSlash'
import { ForwardedRef, forwardRef, useEffect } from 'react' import { ForwardedRef, forwardRef, useEffect, useMemo } from 'react'
import { useLspContext } from 'components/LspProvider' import { useLspContext } from 'components/LspProvider'
import { toSync } from 'lib/utils' import { toSync } from 'lib/utils'
import { reportRejection } from 'lib/trap' import { reportRejection } from 'lib/trap'
@ -44,21 +44,23 @@ export const AllSettingsFields = forwardRef(
settings: { send, context, state }, settings: { send, context, state },
} = useSettingsAuthContext() } = useSettingsAuthContext()
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 = const projectPath =
isFileSettings && isDesktop() isFileSettings && isDesktop()
? decodeURI( ? decodeURIComponent(filteredPathname.slice(lastSlashIndex + 1))
location.pathname
.replace(PATHS.FILE + window.electron.sep, '')
.replace(PATHS.SETTINGS, '')
.slice(
0,
decodeURI(location.pathname).lastIndexOf(
window.electron.path.sep
)
)
)
: undefined : undefined
return projectPath
}, [location.pathname])
function restartOnboarding() { function restartOnboarding() {
send({ send({
type: `set.app.onboardingStatus`, type: `set.app.onboardingStatus`,
@ -197,9 +199,7 @@ export const AllSettingsFields = forwardRef(
<ActionButton <ActionButton
Element="button" Element="button"
onClick={toSync(async () => { onClick={toSync(async () => {
const paths = await getSettingsFolderPaths( const paths = await getSettingsFolderPaths(projectPath)
projectPath ? decodeURIComponent(projectPath) : undefined
)
const finalPath = paths[searchParamTab] const finalPath = paths[searchParamTab]
if (!finalPath) { if (!finalPath) {
return new Error('finalPath undefined') return new Error('finalPath undefined')