[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:
		
							
								
								
									
										13
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal file
									
								
							
							
						
						
									
										13
									
								
								.gitattributes
									
									
									
									
										vendored
									
									
										Normal 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
 | 
			
		||||
@ -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",
 | 
			
		||||
 | 
			
		||||
@ -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(
 | 
			
		||||
                <ActionButton
 | 
			
		||||
                  Element="button"
 | 
			
		||||
                  onClick={toSync(async () => {
 | 
			
		||||
                    const paths = await getSettingsFolderPaths(
 | 
			
		||||
                      projectPath ? decodeURIComponent(projectPath) : undefined
 | 
			
		||||
                    )
 | 
			
		||||
                    const paths = await getSettingsFolderPaths(projectPath)
 | 
			
		||||
                    const finalPath = paths[searchParamTab]
 | 
			
		||||
                    if (!finalPath) {
 | 
			
		||||
                      return new Error('finalPath undefined')
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user