]> Sergey Matveev's repositories - vim-lsp.git/commitdiff
Make room for a large diagnostic message
authorAndreas Louv <andreas@louv.dk>
Mon, 27 Mar 2023 15:07:47 +0000 (17:07 +0200)
committerAndreas Louv <andreas@louv.dk>
Mon, 27 Mar 2023 15:31:22 +0000 (17:31 +0200)
autoload/lsp/diag.vim

index c6017a7e77308c45e81455bf276d7dc8213aed9e..b4c72e67cb34f211401eda853dadb2d27e48a54d 100644 (file)
@@ -250,13 +250,23 @@ def ShowDiagInPopup(diag: dict<any>)
   endif
 
   # Display a popup right below the diagnostics position
+  var msg = diag.message->split("\n")
+  var msglen = msg->reduce((acc, val) => max([acc, val->strcharlen()]), 0)
+
   var ppopts = {}
   ppopts.pos = 'topleft'
   ppopts.line = d.row + 1
-  ppopts.col = d.col
   ppopts.moved = 'any'
-  ppopts.wrap = false
-  popup_create(diag.message->split("\n"), ppopts)
+
+  if msglen > &columns
+    ppopts.wrap = true
+    ppopts.col = 1
+  else
+    ppopts.wrap = false
+    ppopts.col = d.col
+  endif
+
+  popup_create(msg, ppopts)
 enddef
 
 # Display the 'diag' message in a popup or in the status message area