Skip to content

Conversation

meganrogge
Copy link
Contributor

This PR fixes #29816

@meganrogge meganrogge self-assigned this Sep 8, 2021
@meganrogge meganrogge added this to the September 2021 milestone Sep 8, 2021
@meganrogge meganrogge requested a review from Tyriar September 8, 2021 21:48
@@ -305,6 +315,86 @@ export class TerminalService implements ITerminalService {

// Create async as the class depends on `this`
timeout(0).then(() => this._instantiationService.createInstance(TerminalEditorStyle, document.head));

//TODO:@meganrogge is there a better way to do this?
this.onDidReceiveProcessId(async () => await this._refreshDescriptionCwd());
Copy link
Member

Choose a reason for hiding this comment

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

How about we have a new generic pty host message something like this to avoid all this piping through in the future for similar props?

onDidChangeProperty(name: TerminalProperty)

const enum TerminalProperty {
  cwd,
  initialCwd, // This wouldn't change but we could fetch it using a shared mechanism
  // We could add more like below after we validate this is a good idea
  // title,
  // icon,
}

These could always get synced over to the renderer when it changes so accesses are free?

if (i === path.length - index) {
s += `${path[i]}`;
} else {
s += `${isWindows ? '\\' : '/'}${path[i]}`;
Copy link
Member

Choose a reason for hiding this comment

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

This needs to be based on the remote OS, not local one, otherwise we'd see \home\ on Linux

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 collapse the path $HOME into ~ when applicable. $HOMEDRIVE + $HOMEPATH is a good alternative to use for Windows https://superuser.com/a/332872

Copy link
Contributor Author

Choose a reason for hiding this comment

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

(on processManager)

separator: { label: this._configHelper.config.separator }
});

this.getCwd().then(cwd => {
Copy link
Member

Choose a reason for hiding this comment

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

The template may not contain the cwd so we want to fetch it optionally. With the property change event this will become sync, but if we ended up keeping this we would want to make setTitle return a Promise.

@meganrogge
Copy link
Contributor Author

meganrogge commented Sep 9, 2021

Discussed with @Tyriar and deferring the cwdFolder shortening for now see https://github.com/microsoft/vscode/tree/merogge/cwd2

@@ -1486,7 +1492,10 @@ export class TerminalInstance extends Disposable implements ITerminalInstance {
// reset cwd if it has changed, so file based url paths can be resolved
const cwd = await this.getCwd();
if (cwd && this._linkManager) {
this._linkManager.processCwd = cwd;
if (this._linkManager.processCwd !== cwd) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Tryiar suggeseted link manager could listen to the change property event event instead of on _updateProcessCwd (which would actually be better called _refresh)

@meganrogge meganrogge merged commit 6cfc532 into main Sep 9, 2021
@meganrogge meganrogge deleted the merogge/cwd branch September 9, 2021 17:00
chrmarti added a commit that referenced this pull request Sep 10, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Oct 24, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Include cwd in terminal title
2 participants