Provide “Open File” command from Visual Studio Code Source Control pane context menuMultiple cursors in Visual Studio CodeVertical rulers in Visual Studio Code?How to open Visual Studio Code from the command line on OSX?How do you format code in Visual Studio Code (VSCode)How to use Visual Studio Code as Default Editor for GitHow do I collapse sections of code in Visual Studio Code for Windows?Open files always in a new tabHow to filter menu context based on file suffix conditionGit missing in VS Code – No source control providersHow can I add an item to “File menu” in VS Code?

Is "Ram married his daughter" ambiguous?

Is there an in-universe explanation of how Frodo's arrival in Valinor was recorded in the Red Book?

How do French and other Romance language speakers cope with the movable do system?

Does publication of the phone call ruin the basis for impeachment?

How to level a picture frame hung on a single nail?

Does Bank Manager's discretion still exist in Mortgage Lending

What does a textbook look like while you are writing it?

Single tx included in two different blocks

French license plates

As a team leader is it appropriate to bring in fundraiser candy?

Re-entering the UK after overstaying in 2008

Why the first octet of a MAC address always end with a binary 0?

Does the 'java' command compile Java programs?

What did the Federation give the Prophets in exchange for access to the wormhole in DS9?

How can I find places to store/land a private airplane?

Citing CPLEX 12.9

Is there a pattern for handling conflicting function parameters?

Where does the image of a data connector as a sharp metal spike originate from?

Why does it seem the best way to make a living is to invest in real estate?

Why Vegetable Stock is bitter, but Chicken Stock not?

Generating numbers with cubes

Canteen Cutlery Issue

Booting Ubuntu from USB drive on MSI motherboard -- EVERYTHING fails

Knights and Knaves: What does C say?



Provide “Open File” command from Visual Studio Code Source Control pane context menu


Multiple cursors in Visual Studio CodeVertical rulers in Visual Studio Code?How to open Visual Studio Code from the command line on OSX?How do you format code in Visual Studio Code (VSCode)How to use Visual Studio Code as Default Editor for GitHow do I collapse sections of code in Visual Studio Code for Windows?Open files always in a new tabHow to filter menu context based on file suffix conditionGit missing in VS Code – No source control providersHow can I add an item to “File menu” in VS Code?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty
margin-bottom:0;









1















In Visual Studio Code, when I'm using Git source control for a project, I can right-click on a file in source control view and select "Open File" to look at the file as if I had simply opened it from the Explorer pane. How do I implement a similar context menu and command for my own SCM extension? I have it working to the point where files are listed and I can select one to show differences, or select inline command icons to show differences between versions selected in different ways. But I can't figure out how to add a context menu or a command to simply open one of these files instead of a comparison.










share|improve this question






























    1















    In Visual Studio Code, when I'm using Git source control for a project, I can right-click on a file in source control view and select "Open File" to look at the file as if I had simply opened it from the Explorer pane. How do I implement a similar context menu and command for my own SCM extension? I have it working to the point where files are listed and I can select one to show differences, or select inline command icons to show differences between versions selected in different ways. But I can't figure out how to add a context menu or a command to simply open one of these files instead of a comparison.










    share|improve this question


























      1












      1








      1








      In Visual Studio Code, when I'm using Git source control for a project, I can right-click on a file in source control view and select "Open File" to look at the file as if I had simply opened it from the Explorer pane. How do I implement a similar context menu and command for my own SCM extension? I have it working to the point where files are listed and I can select one to show differences, or select inline command icons to show differences between versions selected in different ways. But I can't figure out how to add a context menu or a command to simply open one of these files instead of a comparison.










      share|improve this question














      In Visual Studio Code, when I'm using Git source control for a project, I can right-click on a file in source control view and select "Open File" to look at the file as if I had simply opened it from the Explorer pane. How do I implement a similar context menu and command for my own SCM extension? I have it working to the point where files are listed and I can select one to show differences, or select inline command icons to show differences between versions selected in different ways. But I can't figure out how to add a context menu or a command to simply open one of these files instead of a comparison.







      visual-studio-code vscode-extensions






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 28 at 21:13









      BlueMonkMNBlueMonkMN

      19.3k6 gold badges60 silver badges121 bronze badges




      19.3k6 gold badges60 silver badges121 bronze badges

























          1 Answer
          1






          active

          oldest

          votes


















          0
















          To add to the context menu, a command and a context menu item can be specified in the package.json file. In the contributes block's commands array, add a command like:




          "command": "accurev.openFile",
          "category": "AccuRev",
          "title": "Open file"



          Then refer to the command from a context menu item defined in, for example, the scm/resourceState/context array of the menus block:




          "command": "accurev.openFile",
          "when": "scmProvider == accurev"



          Finally, register a command handler for the new command that uses Visual Studio Code's built-in open command. This can be done in the code that runs during the extension's initial activate function:



          globalState.disposables.push(vscode.commands.registerCommand('accurev.openFile', async (file: AccuRevFile) => 
          try
          await vscode.commands.executeCommand('vscode.open', file.resourceUri);

          catch(err)
          if (globalState)
          globalState.channel.appendLine(err);


          ));


          In this example globalState is just a variable that keeps track of some global variables in the extension, including the list of disposable objects that will be cleaned up with the extension shuts down, and the channel where log text is written for the extension.






          share|improve this answer




























            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/4.0/"u003ecc by-sa 4.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );














            draft saved

            draft discarded
















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406934%2fprovide-open-file-command-from-visual-studio-code-source-control-pane-context%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0
















            To add to the context menu, a command and a context menu item can be specified in the package.json file. In the contributes block's commands array, add a command like:




            "command": "accurev.openFile",
            "category": "AccuRev",
            "title": "Open file"



            Then refer to the command from a context menu item defined in, for example, the scm/resourceState/context array of the menus block:




            "command": "accurev.openFile",
            "when": "scmProvider == accurev"



            Finally, register a command handler for the new command that uses Visual Studio Code's built-in open command. This can be done in the code that runs during the extension's initial activate function:



            globalState.disposables.push(vscode.commands.registerCommand('accurev.openFile', async (file: AccuRevFile) => 
            try
            await vscode.commands.executeCommand('vscode.open', file.resourceUri);

            catch(err)
            if (globalState)
            globalState.channel.appendLine(err);


            ));


            In this example globalState is just a variable that keeps track of some global variables in the extension, including the list of disposable objects that will be cleaned up with the extension shuts down, and the channel where log text is written for the extension.






            share|improve this answer































              0
















              To add to the context menu, a command and a context menu item can be specified in the package.json file. In the contributes block's commands array, add a command like:




              "command": "accurev.openFile",
              "category": "AccuRev",
              "title": "Open file"



              Then refer to the command from a context menu item defined in, for example, the scm/resourceState/context array of the menus block:




              "command": "accurev.openFile",
              "when": "scmProvider == accurev"



              Finally, register a command handler for the new command that uses Visual Studio Code's built-in open command. This can be done in the code that runs during the extension's initial activate function:



              globalState.disposables.push(vscode.commands.registerCommand('accurev.openFile', async (file: AccuRevFile) => 
              try
              await vscode.commands.executeCommand('vscode.open', file.resourceUri);

              catch(err)
              if (globalState)
              globalState.channel.appendLine(err);


              ));


              In this example globalState is just a variable that keeps track of some global variables in the extension, including the list of disposable objects that will be cleaned up with the extension shuts down, and the channel where log text is written for the extension.






              share|improve this answer





























                0














                0










                0









                To add to the context menu, a command and a context menu item can be specified in the package.json file. In the contributes block's commands array, add a command like:




                "command": "accurev.openFile",
                "category": "AccuRev",
                "title": "Open file"



                Then refer to the command from a context menu item defined in, for example, the scm/resourceState/context array of the menus block:




                "command": "accurev.openFile",
                "when": "scmProvider == accurev"



                Finally, register a command handler for the new command that uses Visual Studio Code's built-in open command. This can be done in the code that runs during the extension's initial activate function:



                globalState.disposables.push(vscode.commands.registerCommand('accurev.openFile', async (file: AccuRevFile) => 
                try
                await vscode.commands.executeCommand('vscode.open', file.resourceUri);

                catch(err)
                if (globalState)
                globalState.channel.appendLine(err);


                ));


                In this example globalState is just a variable that keeps track of some global variables in the extension, including the list of disposable objects that will be cleaned up with the extension shuts down, and the channel where log text is written for the extension.






                share|improve this answer















                To add to the context menu, a command and a context menu item can be specified in the package.json file. In the contributes block's commands array, add a command like:




                "command": "accurev.openFile",
                "category": "AccuRev",
                "title": "Open file"



                Then refer to the command from a context menu item defined in, for example, the scm/resourceState/context array of the menus block:




                "command": "accurev.openFile",
                "when": "scmProvider == accurev"



                Finally, register a command handler for the new command that uses Visual Studio Code's built-in open command. This can be done in the code that runs during the extension's initial activate function:



                globalState.disposables.push(vscode.commands.registerCommand('accurev.openFile', async (file: AccuRevFile) => 
                try
                await vscode.commands.executeCommand('vscode.open', file.resourceUri);

                catch(err)
                if (globalState)
                globalState.channel.appendLine(err);


                ));


                In this example globalState is just a variable that keeps track of some global variables in the extension, including the list of disposable objects that will be cleaned up with the extension shuts down, and the channel where log text is written for the extension.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Mar 28 at 22:05









                Gama11

                15.9k6 gold badges33 silver badges53 bronze badges




                15.9k6 gold badges33 silver badges53 bronze badges










                answered Mar 28 at 21:28









                BlueMonkMNBlueMonkMN

                19.3k6 gold badges60 silver badges121 bronze badges




                19.3k6 gold badges60 silver badges121 bronze badges

































                    draft saved

                    draft discarded















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55406934%2fprovide-open-file-command-from-visual-studio-code-source-control-pane-context%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

                    Swift 4 - func physicsWorld not invoked on collision? The Next CEO of Stack OverflowHow to call Objective-C code from Swift#ifdef replacement in the Swift language@selector() in Swift?#pragma mark in Swift?Swift for loop: for index, element in array?dispatch_after - GCD in Swift?Swift Beta performance: sorting arraysSplit a String into an array in Swift?The use of Swift 3 @objc inference in Swift 4 mode is deprecated?How to optimize UITableViewCell, because my UITableView lags

                    Access current req object everywhere in Node.js ExpressWhy are global variables considered bad practice? (node.js)Using req & res across functionsHow do I get the path to the current script with Node.js?What is Node.js' Connect, Express and “middleware”?Node.js w/ express error handling in callbackHow to access the GET parameters after “?” in Express?Modify Node.js req object parametersAccess “app” variable inside of ExpressJS/ConnectJS middleware?Node.js Express app - request objectAngular Http Module considered middleware?Session variables in ExpressJSAdd properties to the req object in expressjs with Typescript