Skip to content

Commit

Permalink
Add setting to configure code command
Browse files Browse the repository at this point in the history
  • Loading branch information
rlivings39 committed Apr 16, 2020
1 parent 55f8e89 commit dd90b93
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 14 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

## [Unreleased]

## [0.0.8] - 2020-04-16

### Added

- Setting `fzf-quick-open.codeCmd` to override the command used to launch `code`. Useful if you use `code-insiders`.

## [0.0.7] - 2020-04-06

### Changed
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "fzf-quick-open",
"displayName": "fzf quick open",
"description": "Open files and folders with fzf",
"version": "0.0.7",
"version": "0.0.8",
"author": "Ryan Livingston",
"license": "MIT",
"repository": {
Expand Down Expand Up @@ -56,6 +56,12 @@
"type": "string",
"default": "find -type d",
"description": "Command used to find directories with fzf. For best performance install fd and use 'fd --type d'"
},
"fzf-quick-open.codeCmd": {
"scope": "window",
"type": "string",
"default": "code",
"description": "Command used to launch VSCode. Set to code-insiders if using insiders build"
}
}
}
Expand All @@ -73,15 +79,15 @@
"@types/chai": "^4.2.8",
"@types/glob": "^7.1.1",
"@types/mocha": "^5.2.6",
"@types/node": "^6.0.40",
"@types/node": "^6.14.10",
"@types/vscode": "^1.33.0",
"chai": "^4.2.0",
"glob": "^7.1.4",
"minimist": "^1.2.5",
"mocha": "^6.1.4",
"nyc": "^15.0.0",
"tslint": "^5.16.0",
"typescript": "^3.5.1",
"typescript": "^3.8.3",
"vscode-test": "^1.0.0"
}
}
11 changes: 7 additions & 4 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,28 +37,31 @@ function moveToPwd(term: vscode.Terminal) {
}

export function activate(context: vscode.ExtensionContext) {
let codeCmd = vscode.workspace.getConfiguration('fzf-quick-open').get('codeCmd') as string ?? "code";
let codeOpenFileCmd = `fzf | xargs -r ${codeCmd}`;
let codeOpenFolderCmd = `fzf | xargs -r ${codeCmd} -a`;
context.subscriptions.push(vscode.commands.registerCommand('fzf-quick-open.runFzfFile', () => {
let term = showFzfTerminal(TERMINAL_NAME, fzfTerminal);
term.sendText('fzf | xargs -r code', true);
term.sendText(codeOpenFileCmd, true);
}));

context.subscriptions.push(vscode.commands.registerCommand('fzf-quick-open.runFzfFilePwd', () => {
let term = showFzfTerminal(TERMINAL_NAME_PWD, fzfTerminalPwd);
moveToPwd(term);
term.sendText('fzf | xargs -r code', true);
term.sendText(codeOpenFileCmd, true);
}));

context.subscriptions.push(vscode.commands.registerCommand('fzf-quick-open.runFzfAddWorkspaceFolder', () => {
let term = showFzfTerminal(TERMINAL_NAME, fzfTerminal);
let findCmd = vscode.workspace.getConfiguration('fzf-quick-open').get('findDirectoriesCmd') as string;
term.sendText(`${findCmd} | fzf | xargs -r code -a`, true);
term.sendText(`${findCmd} | ${codeOpenFolderCmd}`, true);
}));

context.subscriptions.push(vscode.commands.registerCommand('fzf-quick-open.runFzfAddWorkspaceFolderPwd', () => {
let term = showFzfTerminal(TERMINAL_NAME_PWD, fzfTerminalPwd);
let findCmd = vscode.workspace.getConfiguration('fzf-quick-open').get('findDirectoriesCmd') as string;
moveToPwd(term);
term.sendText(`${findCmd} | fzf | xargs -r code -a`, true);
term.sendText(`${findCmd} | ${codeOpenFolderCmd}`, true);
}));

vscode.window.onDidCloseTerminal((terminal) => {
Expand Down

0 comments on commit dd90b93

Please sign in to comment.