Last line removed unexpectly when doing whole file range formatting with stylish-haskell. #3847
Labels
component: formatters
type: bug
Something isn't right: doesn't work as intended, documentation is missing/outdated, etc..
Your environment
Which OS do you use?
Ubuntu on WSL2 on Windows
Which version of GHC do you use and how did you install it?
9.6.3 from ghcup
Which LSP client (editor/plugin) do you use?
Neovim + lspconfig
Which version of HLS do you use and how did you install it?
2.4.0.0 from ghcup
Steps to reproduce
Expected behaviour
The last line should not be removed.
Actual behaviour
The last line get removed unexpectly.
Debug information
After some investigation(took a look at messages passed between client & server and hls's source code), I'm quite sure it is caused by
Ide.PluginUtils.extractTextInRange
Now, let me explain.
Suppose we have codes like:
When I select all lines and call format in neovim, it sends a range formatting message with the range (0, 0) ~ (4, 25), and after range normalization,
extractTextInRange
received the range (0, 0) ~ (5, 0) along with the whole file content.And then,
T.lines
returned aList
with 5Text
inside an further been dropped by 0 and taken by 6. It's taken by 6 but there are only 5Text
available. And when creatingnewS
the lastText
is removed by(T.take (fromIntegral 0))
.Note that this bug is only triggered by a whole file range formatting, in the example above, if I select only the top 4 lines,
T.lines
will be dropped by 0 and taken by 5, and there are 5Text
available so no trouble at all.The text was updated successfully, but these errors were encountered: