Skip to content

Conversation

@mohammadamin16
Copy link
Contributor

The issue: #197949.
The issue was that in a debugging session, user could open some read-only files from the test environment, but when the session ended, there was no need to the read-only tabs to stay open, since the user couldn't edit them and it causes frustration for them.
To test it, you can simply start a debug session and open some read-only files from that debugging environment, like the files in the LOADED_SCRIPTS section and end the session, all the tabs that are read only and opened from the debug context should be closed.

@roblourens
Copy link
Member

stopSession is called when the user requests to stop the session, but I think this should also happen any time the session stops (like if it stops by itself). So this might be a better place for the code:

this._onDidEndSession.fire(session);

@roblourens
Copy link
Member

Also I'm just thinking about whether it would actually be useful to be able to be able to keep these files open in some scenarios where you are actively working with them and don't want to reopen them for each session. But we could add a setting later, if needed.

@mohammadamin16
Copy link
Contributor Author

mohammadamin16 commented Dec 4, 2023

@roblourens
I moved the code

@mohammadamin16 mohammadamin16 force-pushed the close-readonly-tabs branch 2 times, most recently from f0d37d2 to 938790c Compare December 7, 2023 08:51
@connor4312
Copy link
Member

Also I'm just thinking about whether it would actually be useful to be able to be able to keep these files open in some scenarios where you are actively working with them and don't want to reopen them for each session. But we could add a setting later, if needed.

I agree. For example when debugging Node.js things, there are internal scripts that don't exist on disk. One can step into them and e.g. set breakpoints in them between debug sessions. I think this behavior should be under a setting (probably off by default?)

Link to where debug settings are defined:

configurationRegistry.registerConfiguration({

@roblourens
Copy link
Member

I agree re: disabled by default

@mohammadamin16
Copy link
Contributor Author

@microsoft-github-policy-service agree

@mohammadamin16
Copy link
Contributor Author

@connor4312 I added that in the settings.

},
'debug.closeReadonlyTabsOnEnd': {
type: 'boolean',
description: nls.localize({ comment: ['This is the description for a setting'], key: 'closeReadonlyTabsOnEnd' }, "Automatically close the read-only tabs at the end of a debug session."),
Copy link
Member

Choose a reason for hiding this comment

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

I'm not a big fan of this wording, because read-only tabs can come from other places, but I'm not sure how to describe it in a better way without getting superfluous

this.cancelTokens(session.getId());

if (this.configurationService.getValue<IDebugConfiguration>('debug').closeReadonlyTabsOnEnd) {
const editorsToClose = this.editorService.getEditors(EditorsOrder.SEQUENTIAL).filter(({ editor }) => editor.resource?.scheme === DEBUG_SCHEME && editor.isReadonly);
Copy link
Member

Choose a reason for hiding this comment

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

We should make sure the source actually came from the debug session that ended as well to avoid closing the wrong things.

There's a getEncodedDebugData on the Source in debugSource.ts that you can use to extract this information from the editor.resource URI.

@connor4312
Copy link
Member

one more pertinent comment -- sorry, should have noticed that on the first pass too. Then this should be good 👍

@mohammadamin16
Copy link
Contributor Author

Thanks for your review @connor4312
I pushed the necessary changes.

@connor4312 connor4312 enabled auto-merge (squash) December 13, 2023 22:35
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

4 participants