mirror of
https://github.com/nvim-treesitter/nvim-treesitter.git
synced 2026-07-07 14:00:00 -04:00
Added fix for incorrect Java indentation after a closing "}" in a method declaration
Added tests for Java indentation, including one for issue 2571
This commit is contained in:
parent
fb7a56548b
commit
b425a9c813
4 changed files with 36 additions and 0 deletions
|
|
@ -19,4 +19,9 @@
|
|||
"]"
|
||||
] @branch
|
||||
|
||||
[
|
||||
"}"
|
||||
")"
|
||||
] @indent_end
|
||||
|
||||
[(block_comment) (line_comment)] @ignore
|
||||
|
|
|
|||
6
tests/indent/java/issue_2571.java
Normal file
6
tests/indent/java/issue_2571.java
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
// https://github.com/nvim-treesitter/nvim-treesitter/issues/2571
|
||||
class Testo {
|
||||
void foo() {
|
||||
System.out.println("foo");
|
||||
}
|
||||
}
|
||||
2
tests/indent/java/method.java
Normal file
2
tests/indent/java/method.java
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
public class Method {
|
||||
}
|
||||
23
tests/indent/java_spec.lua
Normal file
23
tests/indent/java_spec.lua
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
local Runner = require("tests.indent.common").Runner
|
||||
--local XFAIL = require("tests.indent.common").XFAIL
|
||||
|
||||
local run = Runner:new(it, "tests/indent/java", {
|
||||
tabstop = 2,
|
||||
shiftwidth = 2,
|
||||
softtabstop = 0,
|
||||
expandtab = true,
|
||||
})
|
||||
|
||||
describe("indent Java:", function()
|
||||
describe("whole file:", function()
|
||||
run:whole_file(".", {
|
||||
expected_failures = {},
|
||||
})
|
||||
end)
|
||||
|
||||
describe("new line:", function()
|
||||
run:new_line("method.java", { on_line = 1, text = "void foo() {}", indent = 2 })
|
||||
run:new_line("issue_2571.java", { on_line = 5, text = "void bar() {}", indent = 2 })
|
||||
end)
|
||||
end)
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue