From 849565ffc1c5f40ec0441033a3fdd71cb47232b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Fri, 12 Jan 2024 22:29:58 +0000 Subject: [PATCH 1/5] add new command to open file as horizontal split --- extension.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/extension.js b/extension.js index e15c09d..292e4ff 100644 --- a/extension.js +++ b/extension.js @@ -1,7 +1,7 @@ let assert = require("node:assert"); let path = require("node:path"); let { homedir } = require("node:os"); -let { window, workspace, commands, Uri, EventEmitter, FileType, Selection, languages, Range, Diagnostic, DiagnosticRelatedInformation, Location } = require("vscode"); +let { window, workspace, commands, Uri, EventEmitter, FileType, Selection, languages, Range, Diagnostic, DiagnosticRelatedInformation, Location, ViewColumn } = require("vscode"); /** * The scheme is used to associate vsnetrw documents with the text content provider @@ -183,10 +183,15 @@ function getLinesUnderCursor() { * Opens a file in a vscode editor. * @param {string} fileName */ -async function openFileInVscodeEditor(fileName) { +async function openFileInVscodeEditor(fileName, horizontalSplit = false) { let uri = Uri.file(fileName); await closeExplorer(); - await commands.executeCommand("vscode.open", uri); + + if (horizontalSplit) { + await commands.executeCommand("vscode.open", uri, ViewColumn.Beside); + } else { + await commands.executeCommand("vscode.open", uri); + } } /** @@ -351,7 +356,7 @@ async function openNewExplorer(dir = getInitialDir()) { * editor. If there is a directory under the cursor, then it will open in a * new vsnetrw document. */ -async function openFileUnderCursor() { +async function openFileUnderCursor(horizontalSplit = false) { let relativePath = getLineUnderCursor(); let basePath = getCurrentDir(); let newPath = path.resolve(basePath, relativePath); @@ -361,10 +366,14 @@ async function openFileUnderCursor() { if (stat.type & FileType.Directory) { await openExplorer(newPath); } else { - await openFileInVscodeEditor(newPath); + await openFileInVscodeEditor(newPath, horizontalSplit); } } +async function openFileUnderCursorHorizontalSplit() { + await openFileUnderCursor(true) +} + /** * Opens the parent directory in a vsnetrw document. */ @@ -499,6 +508,7 @@ function activate(context) { context.subscriptions.push( commands.registerCommand("vsnetrw.open", openNewExplorer), commands.registerCommand("vsnetrw.openAtCursor", openFileUnderCursor), + commands.registerCommand("vsnetrw.openAtCursorHorizontalSplit", openFileUnderCursorHorizontalSplit), commands.registerCommand("vsnetrw.openParent", openParentDirectory), commands.registerCommand("vsnetrw.openHome", openHomeDirectory), commands.registerCommand("vsnetrw.rename", renameFileUnderCursor), From 9f3d8d1a3105039e40f6bfb11693884bd47632bc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Mon, 22 Jan 2024 20:20:19 +0000 Subject: [PATCH 2/5] replaced the horizontal flag with viewColumn --- extension.js | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/extension.js b/extension.js index 292e4ff..441caac 100644 --- a/extension.js +++ b/extension.js @@ -182,13 +182,14 @@ function getLinesUnderCursor() { /** * Opens a file in a vscode editor. * @param {string} fileName + * @param {ViewColumn} [viewColumn] */ -async function openFileInVscodeEditor(fileName, horizontalSplit = false) { +async function openFileInVscodeEditor(fileName, viewColumn) { let uri = Uri.file(fileName); await closeExplorer(); - if (horizontalSplit) { - await commands.executeCommand("vscode.open", uri, ViewColumn.Beside); + if (viewColumn) { + await commands.executeCommand("vscode.open", uri, viewColumn); } else { await commands.executeCommand("vscode.open", uri); } @@ -351,12 +352,13 @@ async function openNewExplorer(dir = getInitialDir()) { /** * Attempt to open the file that is currently under the cursor. - * + * * If there is a file under the cursor, it will open in a vscode text * editor. If there is a directory under the cursor, then it will open in a * new vsnetrw document. + * @param {ViewColumn} [viewColumn] */ -async function openFileUnderCursor(horizontalSplit = false) { +async function openFileUnderCursor(viewColumn) { let relativePath = getLineUnderCursor(); let basePath = getCurrentDir(); let newPath = path.resolve(basePath, relativePath); @@ -366,12 +368,12 @@ async function openFileUnderCursor(horizontalSplit = false) { if (stat.type & FileType.Directory) { await openExplorer(newPath); } else { - await openFileInVscodeEditor(newPath, horizontalSplit); + await openFileInVscodeEditor(newPath, viewColumn); } } async function openFileUnderCursorHorizontalSplit() { - await openFileUnderCursor(true) + await openFileUnderCursor(ViewColumn.Beside) } /** From 63b0c8c8c78ea7832419b55affa27ffada78a3a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Tue, 23 Jan 2024 20:22:20 +0000 Subject: [PATCH 3/5] upgrade test-electron --- package.json | 2 +- yarn.lock | 171 ++++++++++++++++----------------------------------- 2 files changed, 55 insertions(+), 118 deletions(-) diff --git a/package.json b/package.json index 9c59f60..5a1552f 100644 --- a/package.json +++ b/package.json @@ -118,7 +118,7 @@ "@types/mocha": "^9.1.1", "@types/node": "^18.0.0", "@types/vscode": "^1.68.1", - "@vscode/test-electron": "^2.1.5", + "@vscode/test-electron": "^2.3.8", "fast-glob": "^3.2.11", "mocha": "^10.0.0", "typescript": "^4.7.4", diff --git a/yarn.lock b/yarn.lock index be064a5..f03d8cb 100644 --- a/yarn.lock +++ b/yarn.lock @@ -48,15 +48,15 @@ resolved "https://registry.yarnpkg.com/@ungap/promise-all-settled/-/promise-all-settled-1.1.2.tgz#aa58042711d6e3275dd37dc597e5d31e8c290a44" integrity sha512-sL/cEvJWAnClXw0wHk85/2L0G6Sj8UB0Ctc1TEMbKSsmpRosqhwj9gWgFRZSrBr2f9tiXISwNhCPmlfqUqyb9Q== -"@vscode/test-electron@^2.1.5": - version "2.1.5" - resolved "https://registry.yarnpkg.com/@vscode/test-electron/-/test-electron-2.1.5.tgz#ac98f8f445ea4590753f5fa0c7f6e4298f08c3b7" - integrity sha512-O/ioqFpV+RvKbRykX2ItYPnbcZ4Hk5V0rY4uhQjQTLhGL9WZUvS7exzuYQCCI+ilSqJpctvxq2llTfGXf9UnnA== +"@vscode/test-electron@^2.3.8": + version "2.3.8" + resolved "https://registry.yarnpkg.com/@vscode/test-electron/-/test-electron-2.3.8.tgz#06a7c50b38cfac0ede833905e088d55c61cd12d3" + integrity sha512-b4aZZsBKtMGdDljAsOPObnAi7+VWIaYl3ylCz1jTs+oV6BZ4TNHcVNC3xUn0azPeszBmwSBDQYfFESIaUQnrOg== dependencies: http-proxy-agent "^4.0.1" https-proxy-agent "^5.0.0" - rimraf "^3.0.2" - unzipper "^0.10.11" + jszip "^3.10.1" + semver "^7.5.2" agent-base@6: version "6.0.2" @@ -120,24 +120,11 @@ base64-js@^1.3.1: resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a" integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA== -big-integer@^1.6.17: - version "1.6.51" - resolved "https://registry.yarnpkg.com/big-integer/-/big-integer-1.6.51.tgz#0df92a5d9880560d3ff2d5fd20245c889d130686" - integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg== - binary-extensions@^2.0.0: version "2.2.0" resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== -binary@~0.3.0: - version "0.3.0" - resolved "https://registry.yarnpkg.com/binary/-/binary-0.3.0.tgz#9f60553bc5ce8c3386f3b553cff47462adecaa79" - integrity sha512-D4H1y5KYwpJgK8wk1Cue5LLPgmwHKYSChkbspQg5JtVuR5ulGckxfR62H3AE9UDkdMC8yyXlqYihuz3Aqg2XZg== - dependencies: - buffers "~0.1.1" - chainsaw "~0.1.0" - bl@^4.0.3: version "4.1.0" resolved "https://registry.yarnpkg.com/bl/-/bl-4.1.0.tgz#451535264182bec2fbbc83a62ab98cf11d9f7b3a" @@ -147,11 +134,6 @@ bl@^4.0.3: inherits "^2.0.4" readable-stream "^3.4.0" -bluebird@~3.4.1: - version "3.4.7" - resolved "https://registry.yarnpkg.com/bluebird/-/bluebird-3.4.7.tgz#f72d760be09b7f76d08ed8fae98b289a8d05fab3" - integrity sha512-iD3898SR7sWVRHbiQv+sHUtHnMvC1o3nW5rAcqnq3uOn07DSAppZYUkIGslDz6gXC7HfunPe7YVBgoEJASPcHA== - boolbase@^1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" @@ -189,11 +171,6 @@ buffer-crc32@~0.2.3: resolved "https://registry.yarnpkg.com/buffer-crc32/-/buffer-crc32-0.2.13.tgz#0d333e3f00eac50aa1454abd30ef8c2a5d9a7242" integrity sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ== -buffer-indexof-polyfill@~1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/buffer-indexof-polyfill/-/buffer-indexof-polyfill-1.0.2.tgz#d2732135c5999c64b277fcf9b1abe3498254729c" - integrity sha512-I7wzHwA3t1/lwXQh+A5PbNvJxgfo5r3xulgpYDB5zckTu/Z9oUK9biouBKQUjEqzaz3HnAT6TYoovmE+GqSf7A== - buffer@^5.5.0: version "5.7.1" resolved "https://registry.yarnpkg.com/buffer/-/buffer-5.7.1.tgz#ba62e7c13133053582197160851a8f648e99eed0" @@ -202,11 +179,6 @@ buffer@^5.5.0: base64-js "^1.3.1" ieee754 "^1.1.13" -buffers@~0.1.1: - version "0.1.1" - resolved "https://registry.yarnpkg.com/buffers/-/buffers-0.1.1.tgz#b24579c3bed4d6d396aeee6d9a8ae7f5482ab7bb" - integrity sha512-9q/rDEGSb/Qsvv2qvzIzdluL5k7AaJOTrw23z9reQthrbF7is4CtlT0DXyO1oei2DCp4uojjzQ7igaSHp1kAEQ== - call-bind@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/call-bind/-/call-bind-1.0.2.tgz#b1d4e89e688119c3c9a903ad30abb2f6a919be3c" @@ -220,13 +192,6 @@ camelcase@^6.0.0: resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a" integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA== -chainsaw@~0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/chainsaw/-/chainsaw-0.1.0.tgz#5eab50b28afe58074d0d58291388828b5e5fbc98" - integrity sha512-75kWfWt6MEKNC8xYXIdRpDehRYY/tNSgwKaJq+dbbDcxORuVrrQ+SEHoWsniVn9XPYfP4gmdWIeDk/4YNp1rNQ== - dependencies: - traverse ">=0.3.0 <0.4" - chalk@^2.4.2: version "2.4.2" resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.4.2.tgz#cd42541677a54333cf541a49108c1432b44c9424" @@ -417,13 +382,6 @@ domutils@^3.0.1: domelementtype "^2.3.0" domhandler "^5.0.1" -duplexer2@~0.1.4: - version "0.1.4" - resolved "https://registry.yarnpkg.com/duplexer2/-/duplexer2-0.1.4.tgz#8b12dab878c0d69e3e7891051662a32fc6bddcc1" - integrity sha512-asLFVfWWtJ90ZyOUHMqk7/S2w2guQKxUI2itj3d92ADHhxUSbCMGi1f1cBcJ7xM1To+pE/Khbwo1yuNbMEPKeA== - dependencies: - readable-stream "^2.0.2" - emoji-regex@^8.0.0: version "8.0.0" resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37" @@ -526,16 +484,6 @@ fsevents@~2.3.2: resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== -fstream@^1.0.12: - version "1.0.12" - resolved "https://registry.yarnpkg.com/fstream/-/fstream-1.0.12.tgz#4e8ba8ee2d48be4f7d0de505455548eae5932045" - integrity sha512-WvJ193OHa0GHPEL+AycEJgxvBEwyfRkN1vhjca23OaPVMCaLCXTd5qAu82AjTcgP1UJmytkOKb63Ypde7raDIg== - dependencies: - graceful-fs "^4.1.2" - inherits "~2.0.0" - mkdirp ">=0.5 0" - rimraf "2" - function-bind@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d" @@ -591,11 +539,6 @@ glob@^7.0.6, glob@^7.1.3: once "^1.3.0" path-is-absolute "^1.0.0" -graceful-fs@^4.1.2, graceful-fs@^4.2.2: - version "4.2.10" - resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.2.10.tgz#147d3a006da4ca3ce14728c7aefc287c367d7a6c" - integrity sha512-9ByhssR2fPVsNZj478qUUbKfmL0+t5BDVyjShtyZZLiK7ZDAArFFfopyOTj0M05wE2tJPisA4iTnnXl2YoPvOA== - has-flag@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" @@ -662,6 +605,11 @@ ieee754@^1.1.13: resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352" integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA== +immediate@~3.0.5: + version "3.0.6" + resolved "https://registry.yarnpkg.com/immediate/-/immediate-3.0.6.tgz#9db1dbd0faf8de6fbe0f5dd5e56bb606280de69b" + integrity sha512-XXOFtyqDjNDAQxVfYxuF7g9Il/IbWmmlQg2MYKOH8ExIT1qg6xc4zyS3HaEEATgs1btfzxq15ciUiY7gjSXRGQ== + inflight@^1.0.4: version "1.0.6" resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9" @@ -670,7 +618,7 @@ inflight@^1.0.4: once "^1.3.0" wrappy "1" -inherits@2, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.0, inherits@~2.0.3: +inherits@2, inherits@^2.0.3, inherits@^2.0.4, inherits@~2.0.3: version "2.0.4" resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c" integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ== @@ -731,6 +679,16 @@ js-yaml@4.1.0: dependencies: argparse "^2.0.1" +jszip@^3.10.1: + version "3.10.1" + resolved "https://registry.yarnpkg.com/jszip/-/jszip-3.10.1.tgz#34aee70eb18ea1faec2f589208a157d1feb091c2" + integrity sha512-xXDvecyTpGLrqFrvkrUSoxxfJI5AH7U8zxxtVclpsUtMCq4JQ290LY8AW5c7Ggnr/Y/oK+bQMbqK2qmtk3pN4g== + dependencies: + lie "~3.3.0" + pako "~1.0.2" + readable-stream "~2.3.6" + setimmediate "^1.0.5" + keytar@^7.7.0: version "7.9.0" resolved "https://registry.yarnpkg.com/keytar/-/keytar-7.9.0.tgz#4c6225708f51b50cbf77c5aae81721964c2918cb" @@ -744,6 +702,13 @@ leven@^3.1.0: resolved "https://registry.yarnpkg.com/leven/-/leven-3.1.0.tgz#77891de834064cccba82ae7842bb6b14a13ed7f2" integrity sha512-qsda+H8jTaUaN/x5vzW2rzc+8Rw4TAQ/4KjB46IwK5VH+IlVeeeje/EoZRpiXvIqjFgK84QffqPztGI3VBLG1A== +lie@~3.3.0: + version "3.3.0" + resolved "https://registry.yarnpkg.com/lie/-/lie-3.3.0.tgz#dcf82dee545f46074daf200c7c1c5a08e0f40f6a" + integrity sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ== + dependencies: + immediate "~3.0.5" + linkify-it@^3.0.1: version "3.0.3" resolved "https://registry.yarnpkg.com/linkify-it/-/linkify-it-3.0.3.tgz#a98baf44ce45a550efb4d49c769d07524cc2fa2e" @@ -751,11 +716,6 @@ linkify-it@^3.0.1: dependencies: uc.micro "^1.0.1" -listenercount@~1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/listenercount/-/listenercount-1.0.1.tgz#84c8a72ab59c4725321480c975e6508342e70937" - integrity sha512-3mk/Zag0+IJxeDrxSgaDPy4zZ3w05PRZeJNnlWhzFz5OkX49J4krc+A8X2d2M69vGMBEX0uyl8M+W+8gH+kBqQ== - locate-path@^6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286" @@ -831,7 +791,7 @@ minimatch@^3.0.3, minimatch@^3.0.4, minimatch@^3.1.1: dependencies: brace-expansion "^1.1.7" -minimist@^1.2.0, minimist@^1.2.3, minimist@^1.2.6: +minimist@^1.2.0, minimist@^1.2.3: version "1.2.6" resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.6.tgz#8637a5b759ea0d6e98702cfb3a9283323c93af44" integrity sha512-Jsjnk4bw3YJqYzbdyBiNsPWHPfO++UGG749Cxs6peCu5Xg4nrena6OVxOYxrQTqww0Jmwt+Ref8rggumkTLz9Q== @@ -841,13 +801,6 @@ mkdirp-classic@^0.5.2, mkdirp-classic@^0.5.3: resolved "https://registry.yarnpkg.com/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz#fa10c9115cc6d8865be221ba47ee9bed78601113" integrity sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A== -"mkdirp@>=0.5 0": - version "0.5.6" - resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6" - integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw== - dependencies: - minimist "^1.2.6" - mocha@^10.0.0: version "10.0.0" resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.0.0.tgz#205447d8993ec755335c4b13deba3d3a13c4def9" @@ -951,6 +904,11 @@ p-locate@^5.0.0: dependencies: p-limit "^3.0.2" +pako@~1.0.2: + version "1.0.11" + resolved "https://registry.yarnpkg.com/pako/-/pako-1.0.11.tgz#6c9599d340d54dfd3946380252a35705a6b992bf" + integrity sha512-4hLB8Py4zZce5s4yd9XzopqwVv/yGNhV1Bl8NTmCq1763HeK2+EwVTv+leGeL13Dnh2wfbqowVPXCIO0z4taYw== + parse-semver@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/parse-semver/-/parse-semver-1.1.1.tgz#9a4afd6df063dc4826f93fba4a99cf223f666cb8" @@ -1060,7 +1018,16 @@ read@^1.0.7: dependencies: mute-stream "~0.0.4" -readable-stream@^2.0.2, readable-stream@~2.3.6: +readable-stream@^3.1.1, readable-stream@^3.4.0: + version "3.6.0" + resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" + integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== + dependencies: + inherits "^2.0.3" + string_decoder "^1.1.1" + util-deprecate "^1.0.1" + +readable-stream@~2.3.6: version "2.3.7" resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.7.tgz#1eca1cf711aef814c04f62252a36a62f6cb23b57" integrity sha512-Ebho8K4jIbHAxnuxi7o42OrZgF/ZTNcsZj6nRKyUmkhLFq8CHItp/fy6hQZuZmP/n3yZ9VBUbp4zz/mX8hmYPw== @@ -1073,15 +1040,6 @@ readable-stream@^2.0.2, readable-stream@~2.3.6: string_decoder "~1.1.1" util-deprecate "~1.0.1" -readable-stream@^3.1.1, readable-stream@^3.4.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-3.6.0.tgz#337bbda3adc0706bd3e024426a286d4b4b2c9198" - integrity sha512-BViHy7LKeTz4oNnkcLJ+lVSL6vpiFeX6/d3oSH8zCW7UxP2onchk+vTGB143xuFjHS3deTgkKoXXymXqymiIdA== - dependencies: - inherits "^2.0.3" - string_decoder "^1.1.1" - util-deprecate "^1.0.1" - readdirp@~3.6.0: version "3.6.0" resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" @@ -1099,14 +1057,7 @@ reusify@^1.0.4: resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== -rimraf@2: - version "2.7.1" - resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.7.1.tgz#35797f13a7fdadc566142c29d4f07ccad483e3ec" - integrity sha512-uWjbaKIK3T1OSVptzX7Nl6PvQ3qAGtKEtVRjRuazjfL3Bx5eI409VZSqgND+4UNnmzLVdPj9FqFJNPqBZFve4w== - dependencies: - glob "^7.1.3" - -rimraf@^3.0.0, rimraf@^3.0.2: +rimraf@^3.0.0: version "3.0.2" resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-3.0.2.tgz#f1a5402ba6220ad52cc1282bac1ae3aa49fd061a" integrity sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA== @@ -1147,6 +1098,13 @@ semver@^7.3.5: dependencies: lru-cache "^6.0.0" +semver@^7.5.2: + version "7.5.4" + resolved "https://registry.yarnpkg.com/semver/-/semver-7.5.4.tgz#483986ec4ed38e1c6c48c34894a9182dbff68a6e" + integrity sha512-1bCSESV6Pv+i21Hvpxp3Dx+pSD8lIPt8uVjRrxAUt/nbswYc+tK6Y2btiULjd4+fnq15PX+nqQDC7Oft7WkwcA== + dependencies: + lru-cache "^6.0.0" + serialize-javascript@6.0.0: version "6.0.0" resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8" @@ -1154,7 +1112,7 @@ serialize-javascript@6.0.0: dependencies: randombytes "^2.1.0" -setimmediate@~1.0.4: +setimmediate@^1.0.5: version "1.0.5" resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285" integrity sha512-MATJdZp8sLqDl/68LfQmbP8zKPLQNV6BIZoIgrscFDQ+RsvK/BxeDQOgyxKKoh0y/8h3BqVFnCqQ/gd+reiIXA== @@ -1278,11 +1236,6 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -"traverse@>=0.3.0 <0.4": - version "0.3.9" - resolved "https://registry.yarnpkg.com/traverse/-/traverse-0.3.9.tgz#717b8f220cc0bb7b44e40514c22b2e8bbc70d8b9" - integrity sha512-iawgk0hLP3SxGKDfnDJf8wTz4p2qImnyihM5Hh/sGvQ3K37dPi/w8sRhdNIxYA1TwFwc5mDhIJq+O0RsvXBKdQ== - tunnel-agent@^0.6.0: version "0.6.0" resolved "https://registry.yarnpkg.com/tunnel-agent/-/tunnel-agent-0.6.0.tgz#27a5dea06b36b04a0a9966774b290868f0fc40fd" @@ -1319,22 +1272,6 @@ underscore@^1.12.1: resolved "https://registry.yarnpkg.com/underscore/-/underscore-1.13.4.tgz#7886b46bbdf07f768e0052f1828e1dcab40c0dee" integrity sha512-BQFnUDuAQ4Yf/cYY5LNrK9NCJFKriaRbD9uR1fTeXnBeoa97W0i41qkZfGO9pSo8I5KzjAcSY2XYtdf0oKd7KQ== -unzipper@^0.10.11: - version "0.10.11" - resolved "https://registry.yarnpkg.com/unzipper/-/unzipper-0.10.11.tgz#0b4991446472cbdb92ee7403909f26c2419c782e" - integrity sha512-+BrAq2oFqWod5IESRjL3S8baohbevGcVA+teAIOYWM3pDVdseogqbzhhvvmiyQrUNKFUnDMtELW3X8ykbyDCJw== - dependencies: - big-integer "^1.6.17" - binary "~0.3.0" - bluebird "~3.4.1" - buffer-indexof-polyfill "~1.0.0" - duplexer2 "~0.1.4" - fstream "^1.0.12" - graceful-fs "^4.2.2" - listenercount "~1.0.1" - readable-stream "~2.3.6" - setimmediate "~1.0.4" - url-join@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/url-join/-/url-join-4.0.1.tgz#b642e21a2646808ffa178c4c5fda39844e12cde7" From 9e419b714b47fd92ad7745def17a8a3c77452d8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Tue, 23 Jan 2024 20:43:25 +0000 Subject: [PATCH 4/5] added test --- extension.js | 4 ++-- tests/extension.test.js | 14 ++++++++++++++ 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/extension.js b/extension.js index 441caac..c8cd0f9 100644 --- a/extension.js +++ b/extension.js @@ -372,7 +372,7 @@ async function openFileUnderCursor(viewColumn) { } } -async function openFileUnderCursorHorizontalSplit() { +async function openFileUnderCursorInHorizontalSplit() { await openFileUnderCursor(ViewColumn.Beside) } @@ -510,7 +510,7 @@ function activate(context) { context.subscriptions.push( commands.registerCommand("vsnetrw.open", openNewExplorer), commands.registerCommand("vsnetrw.openAtCursor", openFileUnderCursor), - commands.registerCommand("vsnetrw.openAtCursorHorizontalSplit", openFileUnderCursorHorizontalSplit), + commands.registerCommand("vsnetrw.openAtCursorInHorizontalSplit", openFileUnderCursorInHorizontalSplit), commands.registerCommand("vsnetrw.openParent", openParentDirectory), commands.registerCommand("vsnetrw.openHome", openHomeDirectory), commands.registerCommand("vsnetrw.rename", renameFileUnderCursor), diff --git a/tests/extension.test.js b/tests/extension.test.js index f1e251d..6a03745 100644 --- a/tests/extension.test.js +++ b/tests/extension.test.js @@ -105,6 +105,20 @@ describe("navigation", () => { let text = getActiveEditorText(); assert.doesNotMatch(text, /\.\.\//); }); + + test("open the a file in a horizontal split", async () => { + const dir = await createTempWorkspace(["a.txt", "b.txt"]); + await execCommand("vscode.open", vscode.Uri.file(path.join(dir, "a.txt"))); + assert.equal(vscode.window.tabGroups.all.length, 1) + await openExplorer(); + await moveToLine("b.txt"); + await execCommand("vsnetrw.openAtCursorInHorizontalSplit"); + assert.equal(vscode.window.tabGroups.all.length, 2) + assert.equal( + vscode.window.activeTextEditor?.document.fileName, + path.join(dir, "b.txt"), + ); + }); }); describe("refresh", () => { From cf216a24f1b7d8fc27d44513e47824274ee3f3ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Flor=C3=AAncio?= Date: Tue, 23 Jan 2024 21:07:49 +0000 Subject: [PATCH 5/5] adding vertical split command --- extension.js | 15 ++++++++++++++- tests/extension.test.js | 29 ++++++++++++++++------------- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/extension.js b/extension.js index c8cd0f9..310481a 100644 --- a/extension.js +++ b/extension.js @@ -373,7 +373,19 @@ async function openFileUnderCursor(viewColumn) { } async function openFileUnderCursorInHorizontalSplit() { - await openFileUnderCursor(ViewColumn.Beside) + await openFileUnderCursor(ViewColumn.Beside); +} + +async function openFileUnderCursorInVerticalSplit() { + await openFileUnderCursor(ViewColumn.Beside); + // saving the reference + // toggling the editor layout (vertical split) will make the editor lose focus + const lastActiveEditor = window.activeTextEditor; + await commands.executeCommand("workbench.action.toggleEditorGroupLayout"); + if (lastActiveEditor) { + // focus the editor again + await window.showTextDocument(lastActiveEditor.document); + } } /** @@ -511,6 +523,7 @@ function activate(context) { commands.registerCommand("vsnetrw.open", openNewExplorer), commands.registerCommand("vsnetrw.openAtCursor", openFileUnderCursor), commands.registerCommand("vsnetrw.openAtCursorInHorizontalSplit", openFileUnderCursorInHorizontalSplit), + commands.registerCommand("vsnetrw.openAtCursorInVerticalSplit", openFileUnderCursorInVerticalSplit), commands.registerCommand("vsnetrw.openParent", openParentDirectory), commands.registerCommand("vsnetrw.openHome", openHomeDirectory), commands.registerCommand("vsnetrw.rename", renameFileUnderCursor), diff --git a/tests/extension.test.js b/tests/extension.test.js index 6a03745..30a5ef5 100644 --- a/tests/extension.test.js +++ b/tests/extension.test.js @@ -106,19 +106,22 @@ describe("navigation", () => { assert.doesNotMatch(text, /\.\.\//); }); - test("open the a file in a horizontal split", async () => { - const dir = await createTempWorkspace(["a.txt", "b.txt"]); - await execCommand("vscode.open", vscode.Uri.file(path.join(dir, "a.txt"))); - assert.equal(vscode.window.tabGroups.all.length, 1) - await openExplorer(); - await moveToLine("b.txt"); - await execCommand("vsnetrw.openAtCursorInHorizontalSplit"); - assert.equal(vscode.window.tabGroups.all.length, 2) - assert.equal( - vscode.window.activeTextEditor?.document.fileName, - path.join(dir, "b.txt"), - ); - }); + ["vsnetrw.openAtCursorInHorizontalSplit", "vsnetrw.openAtCursorInVerticalSplit"].forEach((command) => { + test(`open the a file with ${command}`, async () => { + const dir = await createTempWorkspace(["a.txt", "b.txt"]); + await execCommand("vscode.open", vscode.Uri.file(path.join(dir, "a.txt"))); + assert.equal(vscode.window.tabGroups.all.length, 1); + await openExplorer(); + await moveToLine("b.txt"); + await execCommand(command); + assert.equal(vscode.window.tabGroups.all.length, 2); + assert.equal( + vscode.window.activeTextEditor?.document.fileName, + path.join(dir, "b.txt"), + ); + await execCommand("workbench.action.closeActiveEditor"); + }); + }) }); describe("refresh", () => {