-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
open func.yaml file when clicking on tree view (#258)
- Loading branch information
1 parent
a04c63d
commit 3ea7894
Showing
4 changed files
with
52 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
26 changes: 26 additions & 0 deletions
26
src/functions/function-command/open-yaml-file-in-editor.ts
This file contains 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,26 @@ | ||
/* eslint-disable import/no-cycle */ | ||
/*----------------------------------------------------------------------------------------------- | ||
* Copyright (c) Red Hat, Inc. All rights reserved. | ||
* Licensed under the MIT License. See LICENSE file in the project root for license information. | ||
*-----------------------------------------------------------------------------------------------*/ | ||
|
||
import * as path from 'path'; | ||
import { Uri, window, workspace } from 'vscode'; | ||
import { FunctionNode } from '../function-tree-view/functionsTreeItem'; | ||
|
||
export function openInEditor(context: FunctionNode): void { | ||
if (!context) { | ||
return null; | ||
} | ||
const uriPath = Uri.file(path.join(context.contextPath.fsPath, 'func.yaml')); | ||
workspace.openTextDocument(uriPath).then( | ||
(doc) => { | ||
if (doc) { | ||
// eslint-disable-next-line @typescript-eslint/no-floating-promises | ||
window.showTextDocument(doc, { preserveFocus: true, preview: true }); | ||
} | ||
}, | ||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions | ||
(err) => window.showErrorMessage(`Error loading document: ${err}`), | ||
); | ||
} |
This file contains 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