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

Template Opens Over Existing File #115

Closed
klhes opened this issue Jun 19, 2016 · 2 comments
Closed

Template Opens Over Existing File #115

klhes opened this issue Jun 19, 2016 · 2 comments
Labels
Milestone

Comments

@klhes
Copy link
Contributor

klhes commented Jun 19, 2016

Steps to Reproduce

  1. Select File -> Open File
  2. Select a .tex file and Open
  3. Select File -> Open Template
  4. Select Plain Cover Letter and click Load Template

Actual Result
The template content overwrites the open document's content. If the user saves the document, they will lose the original content.

Expected Result
When a template is opened, the user should be asked if they would like to save the current document (this is addressed in Issue #100) and a new .tex document should open.

@aQaTL
Copy link
Contributor

aQaTL commented Jun 20, 2016

I figured it out:
-when you open a new file, program calls method setCurrentFile from EditorTopComponent,
-it allows program to store info about which file is currently opened,
-but, for now template is being loaded with this code:
etc.setEditorContent(FileService.readFromStream(getClass().getResourceAsStream(templatesList.getSelectedValue().getPath())));
-it just changes text in editor area,
-so, EditorTopComponent still have currentFile set to file that has been opened before,
-so, when you try to save file, it gets file path from EditorTopComponent from currentFile variable and overrides your file.

I hope, that it's understandable. :)

I fixed it, but couldn't (or don't know how) open another pull request without changes in Issue #100, so I just committed them to my currently opened pull request. Sorry for messing up.

@sebbrudzinski
Copy link
Owner

Fixed by @aQaTL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants