-
|
So i have this lua code for the plugin: local micro = import("micro")
local config = import("micro/config")
local shell = import("micro/shell")
config.RegisterCommonOption("csharpfmt", "csfmt", true)
function init()
config.MakeCommand("csfmt", csfmt, config.NoComplete)
end
function onSave(bp)
if bp.Buf:FileType() == "csharp" then
csfmt(bp)
end
return true
end
function csfmt(bp)
bp:Save()
local _, err = shell.RunCommand("dotnet-csharpier --loglevel None " .. bp.Buf.Path)
if err ~= nil then
micro.InfoBar():Error(err)
return
end
bp.Buf:ReOpen()
end
However a code like this: namespace Program
{
public class Program
{
public static void Main(string[] args)
{
Console.WriteLine("Hello World!");
}
}
}Becomes this: namespace Program
{
public class Program
{
public static void Main(string[] args)
{
Con sol e.WriteLine("Hello World!");
}
}
}After saving. |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
The seen phenomenon is actually a bug with Micro: #3303 What's damaged is the loaded content and not the view, however one workaround is clearing the buffer before calling local buf = bp.Buf
buf:Replace(buf:Start(), buf:End(), "")
buf:ReOpen() -- note that it's possible this returns an errorThe code isn't good, but I've done this in a plugin I wrote before: https://github.com/niten94/micro-uchardet/blob/v1.1.2/plug.lua#L47 |
Beta Was this translation helpful? Give feedback.
The seen phenomenon is actually a bug with Micro: #3303
What's damaged is the loaded content and not the view, however one workaround is clearing the buffer before calling
ReOpen():The code isn't good, but I've done this in a plugin I wrote before: https://github.com/niten94/micro-uchardet/blob/v1.1.2/plug.lua#L47