Skip to content

Fix filepicker manual input #146

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

nhamilton1
Copy link

two things i noticed when i was playing around with the new feat of sending images:

  1. when you are in trying to manually type our the file name, you were not able to type i
  2. if you were manually typing out the file name and you tried to press enter to attach the image, it would try to submit the current item you are highlighting over on the directory and not the manually inputted file.

Copy link
Contributor

@PhantomReactor PhantomReactor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if isPathDir {
I think this duplicated code can be removed if we update f.selectedFile in the conditional block with the correct path and then use it in the addAttachmentToMessages() function

@nhamilton1
Copy link
Author

if isPathDir { I think this duplicated code can be removed if we update f.selectedFile in the conditional block with the correct path and then use it in the addAttachmentToMessages() function

sorry about the duplicate code, i am new at go. I want to make sure i understood it correctly before i commit:

		case key.Matches(msg, filePickerKeyMap.Enter):
			var path string
			var isPathDir bool
			if f.cwd.Focused() {
				path = f.cwd.Value()
				fileInfo, err := os.Stat(path)
				if err != nil {
					logging.ErrorPersist("Invalid path")
					return f, cmd
				}
				isPathDir = fileInfo.IsDir()
			} else {
				path = filepath.Join(f.cwdDetails.directory, "/", f.dirs[f.cursor].Name())
				isPathDir = f.dirs[f.cursor].IsDir()
			}
			if isPathDir {
				newWorkingDir := DirNode{parent: f.cwdDetails, directory: path}
				f.cwdDetails.child = &newWorkingDir
				f.cwdDetails = f.cwdDetails.child
				f.cursorChain = f.cursorChain.Push(f.cursor)
				f.dirs = readDir(f.cwdDetails.directory, false)
				f.cursor = 0
				f.cwd.SetValue(f.cwdDetails.directory)
				f.getCurrentFileBelowCursor()
			} else {
				f.selectedFile = path
				return f.addAttachmentToMessage()
			}

removed: path := filepath.Join(f.cwdDetails.directory, "/", f.dirs[f.cursor].Name()) from the if isPathDir block since the path was already set

@PhantomReactor
Copy link
Contributor

This looks fine

@nhamilton1 nhamilton1 requested a review from PhantomReactor May 4, 2025 16:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants