Skip to content

Open files from imported projects on first run after update.#9464

Open
neilcsmith-net wants to merge 1 commit into
apache:masterfrom
neilcsmith-net:gh9443
Open

Open files from imported projects on first run after update.#9464
neilcsmith-net wants to merge 1 commit into
apache:masterfrom
neilcsmith-net:gh9443

Conversation

@neilcsmith-net

@neilcsmith-net neilcsmith-net commented Jun 23, 2026

Copy link
Copy Markdown
Member

Open files from imported projects on first run after update. This follows on from #9449 and uses the now imported attributes to maintain the open files after updating the IDE. This (partly) resolves #9443 - it does not reopen files that are not part of a project.

The code first checks whether any editors are already open, otherwise it interferes with the last focused tab on subsequent runs. The other option would be to check for first run after update, but I'm not sure we have an easy way to do that? Updated to check and store the build version in the project list preferences so that it only executes on the first run after an import.

The real project is extracted from the project lookup as the configuration cannot be read using the ergonomics wrapper project. (bug??)

@neilcsmith-net neilcsmith-net requested a review from mbien June 23, 2026 09:02
@neilcsmith-net neilcsmith-net added UI User Interface ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) labels Jun 23, 2026
@neilcsmith-net neilcsmith-net marked this pull request as draft June 23, 2026 09:02
@mbien mbien added the Editor label Jun 23, 2026
@mbien

mbien commented Jun 23, 2026

Copy link
Copy Markdown
Member

seems to work pretty well!

@neilcsmith-net

Copy link
Copy Markdown
Member Author

Thanks @mbien

I've pushed an update that checks and stores the build number so that this only triggers on first run after import. I think that might be more efficient and better matches the purpose of this change?

@mbien

mbien commented Jun 24, 2026

Copy link
Copy Markdown
Member

I didn't mind the first version since it ran in ~1ms on EDT which is probably not noticeable.

The only suggestion I would have had was to change findFirst() into findAny(). Once done, a jackpot rule I had active matched and it could be simplified into:

                boolean hasEditor = wman.getModes().stream()
                        .filter(mode -> wman.isEditorMode(mode))
                        .flatMap(m -> Stream.of(wman.getOpenedTopComponents(m)))
                        .anyMatch(tc -> tc.getLookup().lookup(DataObject.class) != null);

@mbien mbien left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Preferences version looks also good (also a little faster)

I think the idea behind making it version based is that it allows the property to be imported (a boolean would break the logic here).

@neilcsmith-net

Copy link
Copy Markdown
Member Author

Thanks. I should have used anyMatch (not thinking - I blame the heat!) However, the primary reason I changed is not performance, but to ensure it definitely only runs the first time when dealing with an imported context. After that standard window support takes over. It couldn't be a boolean because that would be imported as-is - needs to be something that differentiates the running IDE version from the one where the data was written. I checked and this also works better and as expected with Tools / Options / Import... after first run.

@mbien

mbien commented Jun 24, 2026

Copy link
Copy Markdown
Member

maybe worth mentioning that this will only open files which actually belong to a project. E.g it didn't open .github/workflows/main.yaml

@neilcsmith-net

Copy link
Copy Markdown
Member Author

I've added an extra note that explains why I said it partly resolves the issue.

@neilcsmith-net neilcsmith-net marked this pull request as ready for review June 24, 2026 15:04
@neilcsmith-net neilcsmith-net added this to the NB31 milestone Jun 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci:dev-build [ci] produce a dev-build zip artifact (7 days expiration, see link on workflow summary page) Editor UI User Interface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Keep/import a list of opened files after NetBeans updates

2 participants