-
Notifications
You must be signed in to change notification settings - Fork 31.8k
Adds custom terminal launch settings #3495
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
Merged
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
2695f19
adds terminal command configuration for windows and linux
abe8d12
makes gnome-terminal default when running on gnome desktop
aa17b93
adds debian check for default terminal
aa3f8d7
adds TerminalService tests
c84a715
Response to ALL_CAPS_NAMING and code org.
ef72b65
Response to typo
5d46df9
Response to configuration property name change
58317c2
Response to move test to electron-browser folder
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/vs/workbench/parts/execution/electron-browser/terminal.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
import fs = require('fs'); | ||
import env = require('vs/base/common/platform'); | ||
|
||
export let DEFAULT_LINUX_TERM = 'x-terminal-emulator'; | ||
|
||
// if we're not on debian and using gnome then | ||
// set default to gnome-terminal | ||
if (env.isLinux | ||
&& fs.existsSync('/etc/debian_version') === false | ||
&& process.env.DESKTOP_SESSION === 'gnome') { | ||
DEFAULT_LINUX_TERM = 'gnome-terminal'; | ||
} | ||
|
||
export const DEFAULT_WINDOWS_TERM = 'cmd'; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
127 changes: 127 additions & 0 deletions
127
src/vs/workbench/parts/execution/test/electron-browser/terminalService.test.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
/*--------------------------------------------------------------------------------------------- | ||
* Copyright (c) Microsoft Corporation. All rights reserved. | ||
* Licensed under the MIT License. See License.txt in the project root for license information. | ||
*--------------------------------------------------------------------------------------------*/ | ||
|
||
'use strict'; | ||
|
||
import {equal} from 'assert'; | ||
import {WinTerminalService, LinuxTerminalService} from 'vs/workbench/parts/execution/electron-browser/terminalService'; | ||
import {DEFAULT_WINDOWS_TERM, DEFAULT_LINUX_TERM} from 'vs/workbench/parts/execution/electron-browser/terminal'; | ||
|
||
suite('Execution - TerminalService', () => { | ||
let mockOnExit; | ||
let mockOnError; | ||
let mockConfig; | ||
|
||
setup(() => { | ||
mockConfig = { | ||
terminal: { | ||
external: { | ||
windowsExec: 'testWindowsShell', | ||
linuxExec: 'testLinuxShell' | ||
} | ||
} | ||
}; | ||
mockOnExit = s => s; | ||
mockOnError = e => e; | ||
}); | ||
|
||
test("WinTerminalService - uses terminal from configuration", done => { | ||
let testShell = 'cmd'; | ||
let testCwd = 'path/to/workspace'; | ||
let mockSpawner = { | ||
spawn: (command, args, opts) => { | ||
// assert | ||
equal(command, testShell, 'shell should equal expected'); | ||
equal(args[args.length - 1], mockConfig.terminal.external.windowsExec, 'terminal should equal expected') | ||
equal(opts.cwd, testCwd, 'opts.cwd should equal expected'); | ||
done(); | ||
return { | ||
on: (evt) => evt | ||
} | ||
} | ||
}; | ||
let testService = new WinTerminalService(mockConfig); | ||
(<any>testService).spawnTerminal( | ||
mockSpawner, | ||
mockConfig, | ||
testShell, | ||
testCwd, | ||
mockOnExit, | ||
mockOnError | ||
); | ||
}); | ||
|
||
test("WinTerminalService - uses default terminal when configuration.terminal.external.windowsExec is undefined", done => { | ||
let testShell = 'cmd'; | ||
let testCwd = 'path/to/workspace'; | ||
let mockSpawner = { | ||
spawn: (command, args, opts) => { | ||
// assert | ||
equal(args[args.length - 1], DEFAULT_WINDOWS_TERM, 'terminal should equal expected') | ||
done(); | ||
return { | ||
on: (evt) => evt | ||
} | ||
} | ||
}; | ||
mockConfig.terminal.external.windowsExec = undefined; | ||
let testService = new WinTerminalService(mockConfig); | ||
(<any>testService).spawnTerminal( | ||
mockSpawner, | ||
mockConfig, | ||
testShell, | ||
testCwd, | ||
mockOnExit, | ||
mockOnError | ||
); | ||
}); | ||
|
||
test("LinuxTerminalService - uses terminal from configuration", done => { | ||
let testCwd = 'path/to/workspace'; | ||
let mockSpawner = { | ||
spawn: (command, args, opts) => { | ||
// assert | ||
equal(command, mockConfig.terminal.external.linuxExec, 'terminal should equal expected'); | ||
equal(opts.cwd, testCwd, 'opts.cwd should equal expected'); | ||
done(); | ||
return { | ||
on: (evt) => evt | ||
} | ||
} | ||
}; | ||
let testService = new LinuxTerminalService(mockConfig); | ||
(<any>testService).spawnTerminal( | ||
mockSpawner, | ||
mockConfig, | ||
testCwd, | ||
mockOnExit, | ||
mockOnError | ||
); | ||
}); | ||
|
||
test("LinuxTerminalService - uses default terminal when configuration.terminal.external.linuxExec is undefined", done => { | ||
let testCwd = 'path/to/workspace'; | ||
let mockSpawner = { | ||
spawn: (command, args, opts) => { | ||
// assert | ||
equal(command, DEFAULT_LINUX_TERM, 'terminal should equal expected') | ||
done(); | ||
return { | ||
on: (evt) => evt | ||
} | ||
} | ||
}; | ||
mockConfig.terminal.external.linuxExec = undefined; | ||
let testService = new LinuxTerminalService(mockConfig); | ||
(<any>testService).spawnTerminal( | ||
mockSpawner, | ||
mockConfig, | ||
testCwd, | ||
mockOnExit, | ||
mockOnError | ||
); | ||
}); | ||
|
||
}); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does just setting the
cwd
work withgnome-terminal
? You may need to pass in--working-directory=path
for that?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
node runs
gnome-terminal
at cwd specified in the options. I tested on Fedora 23 and it does go to the cwd specified. I think it's just a useful flag when someone wants to run from a different path other than the cwdgnome-terminal
was executed from.