Skip to content

Commit 371bc28

Browse files
committed
Added Visual Studio support for Windows
- Reusing the IDE window and jumping to a specific line number is not supported at the same time. Prefering to use the same window over jumping to a line number. - Added test file for launch-editor.
1 parent 0de3896 commit 371bc28

5 files changed

Lines changed: 39 additions & 2 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ To launch files, send requests to the server like the following:
8080
| `rubymine` | [RubyMine](https://www.jetbrains.com/ruby/) ||||
8181
| `sublime` | [Sublime Text](https://www.sublimetext.com/) ||||
8282
| `vim` | [Vim](http://www.vim.org/) || | |
83-
| `visualstudio` | [Visual Studio](https://www.visualstudio.com/vs/) | | ||
83+
| `visualstudio` | [Visual Studio](https://www.visualstudio.com/vs/) | | ||
8484
| `webstorm` | [WebStorm](https://www.jetbrains.com/webstorm/) ||||
8585
| `zed` | [Zed](https://zed.dev/) || ||
8686

packages/launch-editor/editor-info/windows.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,6 @@ module.exports = [
2323
'goland64.exe',
2424
'rider.exe',
2525
'rider64.exe',
26-
'trae.exe'
26+
'trae.exe',
27+
'devenv.exe'
2728
]

packages/launch-editor/get-args.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,9 @@ module.exports = function getArgumentsForPosition (
6262
case 'rider':
6363
case 'rider64':
6464
return ['--line', lineNumber, '--column', columnNumber, fileName]
65+
case 'devenv':
66+
case 'visualstudio':
67+
return ['/edit', fileName]
6568
}
6669

6770
if (process.env.LAUNCH_EDITOR) {
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
const assert = require('node:assert/strict')
2+
const { describe, test } = require('node:test')
3+
const getArgumentsForPosition = require('./get-args.js')
4+
5+
describe('getArgumentsForPosition', () => {
6+
test('should format arguments for Visual Studio (devenv)', () => {
7+
const result = getArgumentsForPosition('devenv.exe', 'test.js', 10, 5)
8+
assert.deepEqual(result, ['/edit', 'test.js'])
9+
})
10+
11+
test('should format arguments for Visual Studio (visualstudio)', () => {
12+
const result = getArgumentsForPosition('visualstudio', 'src/app.js', 42, 12)
13+
assert.deepEqual(result, ['/edit', 'src/app.js'])
14+
})
15+
16+
test('should format arguments for Visual Studio with default column', () => {
17+
const result = getArgumentsForPosition('devenv.exe', 'main.cpp', 100)
18+
assert.deepEqual(result, ['/edit', 'main.cpp'])
19+
})
20+
21+
test('should format arguments for VS Code for comparison', () => {
22+
const result = getArgumentsForPosition('code.exe', 'test.js', 10, 5)
23+
assert.deepEqual(result, ['-r', '-g', 'test.js:10:5'])
24+
})
25+
26+
test('should format arguments for Notepad++ for comparison', () => {
27+
const result = getArgumentsForPosition('notepad++.exe', 'test.txt', 15, 8)
28+
assert.deepEqual(result, ['-n15', '-c8', 'test.txt'])
29+
})
30+
})

packages/launch-editor/package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33
"version": "2.11.1",
44
"description": "launch editor from node.js",
55
"main": "index.js",
6+
"scripts": {
7+
"test": "node --test"
8+
},
69
"repository": {
710
"type": "git",
811
"url": "git+https://github.com/yyx990803/launch-editor.git"

0 commit comments

Comments
 (0)