For some programming language there are some string formatting functions like String.format("%d", a) or printf("%d", a"). If lualine is combined with nvim_treesitter#statusline like the following:
It will sometimes crash when the code has % in it.
For example,
package samples.quickstart.service.pojo;
import java.util.HashMap;
public class StockQuoteService {
private HashMap map = new HashMap();
public double getPrice(String symbol) {
Double price = (Double) map.get(symbol);
if(price != null){
return price.doubleValue();
}
return 42.00;
}
private void writeLog(String symbol, double price) {
map.put(symbol, new Double(price));
try {
Path p = Paths.get("/home", "user", "Document", "templogs", "folde" String.format("%d.log", System.currentTimeMillis()));
}
}
}
the %d should be %%d in status line text, but when the line gets too long nvim_treesitter#statusline will try to trim the output text and replace with ..., and something the extra % get trimmed off, which may look something like the following
and this would throw. (this trigger may differ for different screen widths)
one cheap solution is to wrap vim.api.nvim_win_set_option with pcall. another solution would be to make sure vim.api.nvim_win_set_option is never called with a single %.
For some programming language there are some string formatting functions like
String.format("%d", a)
orprintf("%d", a")
. If lualine is combined withnvim_treesitter#statusline
like the following:It will sometimes crash when the code has
%
in it.For example,
the
%d
should be%%d
in status line text, but when the line gets too longnvim_treesitter#statusline
will try to trim the output text and replace with...
, and something the extra%
get trimmed off, which may look something like the followingand this would throw. (this trigger may differ for different screen widths)
one cheap solution is to wrap
vim.api.nvim_win_set_option
withpcall
. another solution would be to make surevim.api.nvim_win_set_option
is never called with a single%
.