Skip to content
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

Text is removed when cancelling the open dialog #4

Closed
gentleadam opened this issue Nov 27, 2018 · 13 comments
Closed

Text is removed when cancelling the open dialog #4

gentleadam opened this issue Nov 27, 2018 · 13 comments
Labels
bug Something isn't working
Milestone

Comments

@gentleadam
Copy link
Contributor

After opening the open dialog from the file menu and clicking close the text inputted in the text box disappears because the path cannot be found.

The open dialog needs to be handled better so that the text box only changes on a successful opening.

Get-Content : Cannot bind argument to parameter 'Path' because it is an empty string. At C:\Users\adam\Documents\GitHub\Personal\Jottey\Jottey.ps1:70 char:28 $InputData = Get-Content $global:InputFile CategoryInfo : InvalidData: (:) [Get-Content], ParameterBindingValidationException FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,Microsoft.PowerShell.Commands.GetContentCommand

@gllms gllms added the bug Something isn't working label Nov 27, 2018
@gllms
Copy link
Owner

gllms commented Nov 27, 2018

Yeah, that's some serious bug.
I see you've already been working on this: https://github.com/milkshakespoon/Jottey/commit/...
Is this working code?

@gllms gllms assigned gllms and unassigned gllms Nov 27, 2018
@gentleadam
Copy link
Contributor Author

gentleadam commented Nov 28, 2018

Yeah, that's some serious bug.
I see you've already been working on this: https://github.com/milkshakespoon/Jottey/commit/...
Is this working code?

Trying to work on it... Although never used Windows forms before. It's kind of working, but not quite there. You might want to test it and see if you can make it better?

I am unable to work out where the file is saved by default when no file has been opened?

@gentleadam
Copy link
Contributor Author

I think I've just fixed this. https://github.com/milkshakespoon/Jottey/commit/1e8e22697806ab5f00f2ee851ff940cd7c5bb73b

I'll let you have a test and then I can create a pull request if you're happy with the code. I'm learning as I'm going with this, so forgive me if my code is atrocious.

@gllms
Copy link
Owner

gllms commented Nov 28, 2018

The file isn't saved when no file is opened 😳. It doesn't make sense indeed, you are unable to save your text you wrote before opening a file.
i've added an issue for it: #5

@gllms
Copy link
Owner

gllms commented Nov 28, 2018

I'm sorry, but my computer is gone for a few days for maintenance, so I'm not able to test it right now.

@gentleadam
Copy link
Contributor Author

gentleadam commented Nov 28, 2018

The file isn't saved when no file is opened 😳. It doesn't make sense indeed, you are unable to save your text you wrote before opening a file.
i've added an issue for it: #5

Not quite sure what you're saying here. I noticed every time I restart Jottey the text file is wiped. I'm guessing because it doesn't attempt to open the last file you saved so overwrites it with no text as per the opening text box.

I'm sorry, but my computer is gone for a few days for maintenance, so I'm not able to test it right now.

No worries, continue to add issues and I'll see if I can fix them. Like you mentioned in Reddit, likely nobody really has a use for this text editor, but I want a small project to learn from.

@gllms
Copy link
Owner

gllms commented Nov 28, 2018

Not quite sure what you're saying here. I noticed every time I restart Jottey the text file is wiped. I'm guessing because it doesn't attempt to open the last file you saved so overwrites it with no text as per the opening text box.

You already set the $global:InputFile. So when it autosaves, it saves the contents of the (empty) textbox to the filename you provided. I didn't set the variable at first, and Jottey also doesn't remember the last opened file, so nothing happens, because Jottey checks if the $global:InputFile is empty:

if ($global:InputFile -ne "") { 
  # If the filename not equals "", then...
  Set-Content $global:InputFile $TextBox.Text
}

@gentleadam
Copy link
Contributor Author

Not quite sure what you're saying here. I noticed every time I restart Jottey the text file is wiped. I'm guessing because it doesn't attempt to open the last file you saved so overwrites it with no text as per the opening text box.

You already set the $global:InputFile. So when it autosaves, it saves the contents of the (empty) textbox to the filename you provided. I didn't set the variable at first, and Jottey also doesn't remember the last opened file, so nothing happens, because Jottey checks if the $global:InputFile is empty:

if ($global:InputFile -ne "") { 
  # If the filename not equals "", then...
  Set-Content $global:InputFile $TextBox.Text
}

Ah yes! I understand that now. I did set the path you're right. I wanted to test what would happen. However, despite having the path set Jottey always wipes the file and displays a blank text box. I don't think we have any code handling this?

@gllms gllms closed this as completed in d8d38f0 Nov 29, 2018
@gllms
Copy link
Owner

gllms commented Nov 29, 2018

Now we have.
My pc is back, btw.

@gentleadam
Copy link
Contributor Author

Awesome! I thought I was going to submit a pull request. But all good.

@gllms
Copy link
Owner

gllms commented Nov 29, 2018

We probably should assign each issue to a specific person to prevent confusion.

@gllms
Copy link
Owner

gllms commented Nov 29, 2018

I thought I was going to submit a pull request.

I'm sorry. I got a bit over-enthusiastic after getting my pc back.

@gentleadam
Copy link
Contributor Author

Yeah we can assign these tasks if you like. Might be nice. No worries. I've created a new pull request now, awaiting your auth.

@gllms gllms added this to the v1.0 milestone Dec 8, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants