首页 > 其他分享 >vscode插件开发----获得当前打开文档对应的工作区根目录

vscode插件开发----获得当前打开文档对应的工作区根目录

时间:2023-06-04 22:25:51浏览次数:30  
标签:selectedWorkspaceFolder 插件 打开文档 vscode editor 根目录

代码如下:

export function activate(context:any) {
  // 注册一个命令
  let disposable = vscode.commands.registerCommand('codeStat.countCurFile', function () {
    let editor = vscode.window.activeTextEditor;
        if (editor) {
          const currentDocumentUri = editor.document.uri;
          const selectedWorkspaceFolder = vscode.workspace.getWorkspaceFolder(currentDocumentUri);
          if (selectedWorkspaceFolder) {
            vscode.window.showInformationMessage(selectedWorkspaceFolder.uri.fsPath);
          }
        }
  });
  context.subscriptions.push(disposable);   // 插件退出时释放资源
}

标签:selectedWorkspaceFolder,插件,打开文档,vscode,editor,根目录
From: https://www.cnblogs.com/huzhongqiang/p/17456499.html

相关文章

  • 分页插件样式
    <head><metacharset="UTF-8"><title>11分页插件样式</title><style>.pagea,.prev-page,.next-page{display:inline-block;width:36px;height:36px;......
  • 常用插件的使用—grunt入门指南(下)
    less/sass/stylus预编译在前端工程中使用css预编译器(less/sass/stylus)用于弥补css的语言缺陷,基本上是标配了,其中less和sass用的最多,但明河最喜欢使用的是stylus,grunt官方有对应的编译插件。这里以grunt-contrib-stylus为例。stylus:{options:{//......
  • jQuery Backstretch动态设置背景图片插件
    [url]http://www.2cto.com/kf/201411/348425.html[/url]官方:[url]https://github.com/srobbin/jquery-backstretch[/url]<scriptsrc="Scripts/jquery-1.8.2.min.js"></script><scriptsrc="Scripts/jquery.backstretc......
  • Eclipse插件开发
    Eclipse插件开发之基础篇(1)插件开发的基础知识[url]http://www.360doc.com/content/12/0322/18/9210133_196714278.shtml[/url]Eclipse插件开发之基础篇(2)第一个Eclipse插件[url]http://www.360doc.com/content/12/0322/18/9210133_196715402.shtml[/u......
  • jQuery动画插件: Velocity.js
    官方:[url]http://julian.com/research/velocity/[/url]介绍:[url]http://www.w3ctech.com/topic/1403[/url]使用Velocity.js改善用户体验[url]http://www.w3ctrain.com/2015/11/15/faster-ui-animations-with-velocity-js/[/url]使用VELOCITY.JS来改善和......
  • vscode插件开发----如何向输出通道中输出信息
    插件有时候需要输出一些信息,那么如何在输出通道中显示呢?使用如下代码即可:varoutputChannel:vscode.OutputChannel;//输出通道/***输出信息到控制台上,输出通道为MyCoder*@parammessage输出的文本信息*/exportfunctionmylog(message:string){if(outputC......
  • vscode插件开发----获得当前打开的文件名
    采用下面代码即可:importvscode=require('vscode');//激活函数,是首先要调用的exportfunctionactivate(context:any){//注册一个命令letdisposable=vscode.commands.registerCommand('codeStat.countCurFile',function(){leteditor=vscode.window.......
  • YouCompleteMe插件安装
    Vundle安装YouCompleteMe安装YouCompleteMe对软件版本要求,编译python默认都是静态库,YouCompleteMe需要动态库ProblemsinstallingPython3with--enable-sharedexportLD_RUN_PATH=~/opt/python3.10/lib;./configure--prefix=~/opt/python3.10/--enable-sharedexpo......
  • 分享10个最好的jQuery表单插件
    为web设计或者开发者来说,表单是我们经常需要打交道的设计元素之一。不论你开发登陆功能,在线购物功能,或者是注册功能,你都需要使用表单来执行用户输入。但其实并不是很多开发人员都关心开发或者设计表单元素。而表单设计最重要的目的在于能够将表单设计超越它本身结构以达到使用体......
  • JQuery 导航插件和图表
    [b][color=red]导航代码例子集[/color][/b]:[url]http://www.skyuu.net/jscode/adsCode/caidandaohang/[/url]15个最新的jQuery导航菜单插件[url]http://www.bobd.cn/resources/others/50381.html[/url]这篇文章中,将向大家展示采用jQuery最新技术的导航菜单......