diff --git a/native/libcst/src/nodes/module.rs b/native/libcst/src/nodes/module.rs index 656b7d39..ff9a2a73 100644 --- a/native/libcst/src/nodes/module.rs +++ b/native/libcst/src/nodes/module.rs @@ -77,12 +77,8 @@ impl<'r, 'a> Inflate<'a> for DeflatedModule<'r, 'a> { } } if let Some(num) = last_indented { - if num + 1 == footer.len() { - footer = vec![]; - } else { - let (_, rest) = footer.split_at(num + 1); - footer = rest.to_vec(); - } + let (_, rest) = footer.split_at(num); + footer = rest.to_vec(); } } else { swap(&mut header, &mut footer); diff --git a/native/libcst/tests/fixtures/trailing_whitespace.py b/native/libcst/tests/fixtures/trailing_whitespace.py new file mode 100644 index 00000000..5a01c197 --- /dev/null +++ b/native/libcst/tests/fixtures/trailing_whitespace.py @@ -0,0 +1,5 @@ + + +x = 42 +print(x) + \ No newline at end of file