Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions extension.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ const features = [
require("./src/closeEditors"),
require("./src/openProject"),
require("./src/columnMovements"),
require("./src/openQuickly"),
]

function activate(context) {
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,10 @@
{
"title": "TextMate: Open Recent Project",
"command": "vscode-textmate.openProject"
},
{
"title": "TextMate: Open Quickly…",
"command": "vscode-textmate.openQuickly"
}
],
"keybindings": [
Expand Down Expand Up @@ -998,6 +1002,10 @@
{
"key": "cmd+shift+o",
"command": "vscode-textmate.openProject"
},
{
"key": "cmd+alt+t",
"command": "vscode-textmate.openQuickly"
}
]
},
Expand Down
75 changes: 75 additions & 0 deletions src/openQuickly.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
const vscode = require("vscode")
const path = require("path")

function activate(context) {
// Register a command to open a quick pick menu
context.subscriptions.push(
vscode.commands.registerCommand("vscode-textmate.openQuickly", async () => {
const workspaceFolders = vscode.workspace.workspaceFolders
if (!workspaceFolders) {
vscode.window.showErrorMessage("No workspace folders found.")
return
}
const searchConfig = vscode.workspace.getConfiguration("search")
const fileUris = await vscode.workspace.findFiles(
"**/*",
searchConfig.get("exclude"),
)
const items = fileUris.map((uri) => {
const filePath = uri.fsPath
const fileName = path.basename(filePath)
const folderName = path.basename(path.dirname(filePath))
return {
label: fileName,
description: folderName,
uri,
}
})
const selectedFiles = [await vscode.window.showQuickPick(items, {
canPickMany: false,
})]

let activeEditorIndex = vscode.window.visibleTextEditors.findIndex(
(editor) => editor.document === vscode.window?.activeTextEditor?.document,
)
console.log({ activeEditorIndex, selectedFiles })


selectedFiles.forEach(async (selected) => {
const alreadyOpen = vscode.window.visibleTextEditors.find(
(editor) => editor.document.uri === selected.uri,
)

if (alreadyOpen) {
vscode.window.showTextDocument(alreadyOpen.document)
} else {
const document = await vscode.workspace.openTextDocument(selected.uri)
vscode.window.showTextDocument(document, { preview: false })
}

// let activeEditorIndex = 0 // vscode.window.tabGroups.activeTabGroup.indexOf(vscode.window.activeTextEditor)
// vscode.window.showTextDocument(document)
// vscode.commands.executeCommand('workbench.action.moveEditor', { to: 'right' });
// const document = await vscode.workspace.openTextDocument(selected.uri)
// const viewColumn = activeEditor
// ? activeEditor.viewColumn + 1
// : vscode.ViewColumn.One

// vscode.window.showTextDocument(document, { preview: false })
console.log({ activeEditorIndex })
vscode.commands.executeCommand("moveActiveEditor", {
to: "position",
by: "tab",
value: activeEditorIndex++,
})
})
}),
)
}

const deactivate = () => {}

module.exports = {
activate,
deactivate,
}
16 changes: 16 additions & 0 deletions src/openQuickly.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"contributes": {
"commands": [
{
"title": "TextMate: Open Quickly…",
"command": "vscode-textmate.openQuickly"
}
],
"keybindings": [
{
"key": "cmd+alt+t",
"command": "vscode-textmate.openQuickly"
}
]
}
}