我正在处理一个 vsix 项目,我需要在其中获取有关本地 git 目录的信息。我正在关注这篇文章。当我使用LibGit2Sharp库时,出现如下图和错误中所述的异常:-
我该如何解决这个问题?
VS 版本详情:
视觉工作室 2019
.Net 框架 4.7.2
我正在开发 vscode TextEditorEdit 扩展。在这里,我需要根据 api 响应内容,在以编辑器打开文件后将光标置于指定行号上。我怎样才能做到这一点?或者什么类或接口提供了执行此操作的功能?
以下是我尝试实现此目的的代码。但两者都不起作用。甚至没有引发任何异常或错误。
尽管这是在编辑器上正确打开并显示文件。但当我尝试更改光标位置时没有任何效果。
vscode.window.showTextDocument()分配 并分配editor.selection。这对编辑器没有影响。vscode.workspace.openTextDocument(openPath).then(async doc => {
let pos1 = new vscode.Position(57, 40)
let pos2 = new vscode.Position(57, 42)
let sel = new vscode.Selection(pos1,pos2)
let rng = new vscode.Range(pos1, pos2)
vscode.window.showTextDocument(doc, vscode.ViewColumn.One).then((editor: vscode.TextEditor) => {
editor.selection = sel
//editor.revealRange(rng, vscode.TextEditorRevealType.InCenter)
});
});
Run Code Online (Sandbox Code Playgroud)
我也尝试揭示范围,editor.revealRange(rng, vscode.TextEditorRevealType.InCenter)但也没有效果。
options?:在 中添加参数vscode.window.showTextDocument()。但这也没有任何作用。请看下面的代码——vscode.workspace.openTextDocument(openPath).then(async doc => {
let pos1 = new vscode.Position(57, 40)
let pos2 = new vscode.Position(57, 42)
let …Run Code Online (Sandbox Code Playgroud) 我正在开发一个 VSIX 项目,我想获取正在 VS IDE(或实验窗口)中编辑的当前文件名和路径(相对于该项目)?我怎样才能做到这一点?
我尝试了以下代码:
var currentDocInfo = this._textDocumentFactoryService.TryGetTextDocument(this.view.TextBuffer, out this.TextDocument);
if (currentDocInfo)
{
string test = this.TextDocument.FilePath;
MessageBox.Show(test);
}
else
{
//MessageBox.Show("Nothingg!");
}
Run Code Online (Sandbox Code Playgroud)
此代码返回当前打开文件的绝对路径。我需要获取相对于当前项目/解决方案的路径。如果我能够获得解决方案的名称,我将找到该项目的相对路径。
如果我添加代码:System.IO.Path.GetDirectoryName(dte.Solution.FullName);
它将返回我的 TextAdornment 类(一个类,通过安装整个插件来管理编辑器任务,这里我正在编写 dte.ActiveDocument.FullName; 代码)的路径详细信息。但我想要在我的实验窗口中打开的文件的文件详细信息。
c# extensibility visual-studio vsix visual-studio-extensions
我有一个像单个字符串一样的列表 -"['2','4','5','1']"当计算每个字符时,它的长度为 17。
现在我想将它解析为列表对象,例如 -['2','4','5','1']其长度为 4 作为列表中的元素数。
我怎样才能在 C# 中做到这一点?
可以不做基本的字符串操作吗?如果是,那么如何?
c# ×3
vsix ×3
arrays ×1
editor ×1
libgit2sharp ×1
list ×1
string ×1
text-editor ×1
typescript ×1