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

Automatically remove editors for deleted files #894

Merged
merged 1 commit into from
Mar 21, 2022

Conversation

msujew
Copy link
Contributor

@msujew msujew commented Mar 8, 2022

Motivation

Closes #648

Change description

Listens to any changes of open editors and removes them if the type indicates that the underlying file has been deleted.

Reviewer checklist

  • PR addresses a single concern.
  • The PR has no duplicates (please search among the Pull Requests before creating one)
  • PR title and description are properly filled.
  • Docs have been added / updated (for bug fixes / features)

Copy link
Contributor

@AlbyIanna AlbyIanna left a comment

Choose a reason for hiding this comment

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

LGTM

@AlbyIanna AlbyIanna requested a review from per1234 March 9, 2022 15:57
Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

Tested on Windows and Linux and this fixes #648 for me in the following cases:

  • Saved sketch
  • New sketch
  • Pulling to remote sketchbook after file deletion on Arduino Cloud

However, I did encounter a problem with unsaved sketches.

I don't know whether this would be considered in scope for this PR, or if it is more that this PR is only allowing us to reach a bug that has always existed, which should be fixed separately.

  1. Select File > Preferences... from the Arduino IDE menus.
  2. Uncheck the box next to "🗹 Auto save".
  3. Click the OK button.
  4. Click the downward pointing triangle button on the right side of the editor toolbar.
  5. Select "New Tab" from the menu.
  6. In the "Name for new file" field, type foo.
  7. Click the OK button.
    The sketch will now contain a "foo.ino" tab.
  8. Add some text to the "foo.ino" editor to make it "dirty".
    (added tab is saved even with auto save off, but that is an unrelated bug)
  9. Click the downward pointing triangle button on the right side of the tab bar.
  10. Select "Delete" from the menu.
  11. Click the OK button on the "Move File to Trash" dialog.

🐛 I am presented with this perplexing dialog:

image

  • Don't save - file is deleted, tab is removed from editor
  • Cancel/X icon - file is deleted, tab is left in the editor with the "(deleted)" state
  • Save - file is preserved, 🙁 tab is removed from the editor

Since the user has already been asked for confirmation about the deletion in the "Move File to Trash" dialog, I don't see any value in this additional "Do you want to save the changes you made to foo.ino (deleted)?" dialog.

@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Mar 9, 2022
@AlbyIanna
Copy link
Contributor

I think this might be related to #893. Probably solving it in that PR will make this one work properly too.

Let's wait for #893 to be merged before doing anything here.

@msujew
Copy link
Contributor Author

msujew commented Mar 15, 2022

@AlbyIanna You're right, I will address this issue in #893 probably 👍

@msujew
Copy link
Contributor Author

msujew commented Mar 17, 2022

@per1234 Since #893 might take a while to get finished, I updated this PR to fix the issue you noticed. I found a clean solution. Please take another look :)

@msujew msujew requested a review from per1234 March 17, 2022 12:50
Copy link
Contributor

@per1234 per1234 left a comment

Choose a reason for hiding this comment

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

The problem I reported in my previous review no longer occurs and it also solves #648 as before.

Thanks @msujew!

Copy link
Contributor

@AlbyIanna AlbyIanna left a comment

Choose a reason for hiding this comment

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

LGTM! 🚀

@AlbyIanna AlbyIanna merged commit 4de7737 into main Mar 21, 2022
@AlbyIanna AlbyIanna deleted the msujew/deleted-editors branch March 21, 2022 09:44
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Tab remains in UI after deletion
3 participants