editor: Use unbounded shifts for chunk bitmaps (#40879)
This simplifies some code and is also more correct in some others (I believe some of these might've overflowed causing panics in sentry) Release Notes: - N/A *or* Added/Fixed/Improved ...
This commit is contained in:
@@ -51,7 +51,7 @@ use text::{
|
||||
use theme::SyntaxTheme;
|
||||
use util::{post_inc, rel_path::RelPath};
|
||||
|
||||
const NEWLINES: &[u8] = &[b'\n'; u8::MAX as usize];
|
||||
const NEWLINES: &[u8] = &[b'\n'; rope::Chunk::MASK_BITS];
|
||||
|
||||
#[derive(Debug, Default, Clone, Copy, Hash, PartialEq, Eq, PartialOrd, Ord)]
|
||||
pub struct ExcerptId(u32);
|
||||
@@ -7730,7 +7730,7 @@ impl<'a> Iterator for MultiBufferChunks<'a> {
|
||||
let split_idx = diff_transform_end - self.range.start;
|
||||
let (before, after) = chunk.text.split_at(split_idx);
|
||||
self.range.start = diff_transform_end;
|
||||
let mask = (1 << split_idx) - 1;
|
||||
let mask = 1u128.unbounded_shl(split_idx as u32).wrapping_sub(1);
|
||||
let chars = chunk.chars & mask;
|
||||
let tabs = chunk.tabs & mask;
|
||||
|
||||
@@ -7882,7 +7882,9 @@ impl<'a> Iterator for ExcerptChunks<'a> {
|
||||
|
||||
if self.footer_height > 0 {
|
||||
let text = unsafe { str::from_utf8_unchecked(&NEWLINES[..self.footer_height]) };
|
||||
let chars = (1 << self.footer_height) - 1;
|
||||
let chars = 1u128
|
||||
.unbounded_shl(self.footer_height as u32)
|
||||
.wrapping_sub(1);
|
||||
self.footer_height = 0;
|
||||
return Some(Chunk {
|
||||
text,
|
||||
|
||||
Reference in New Issue
Block a user