Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .pipelines/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ extends:
template: v2/Microsoft.${{parameters.official}}.yml@GovernedTemplates
parameters:
featureFlags:
autoBaseline: false
WindowsHostVersion:
Version: 2022
Network: R1
Expand Down Expand Up @@ -112,7 +113,7 @@ extends:
- task: RustInstaller@1
displayName: Install Rust toolchain
inputs:
rustVersion: ms-prod
rustVersion: ms-prod@llvm
additionalTargets: x86_64-pc-windows-msvc aarch64-pc-windows-msvc
# URL of an Azure Artifacts feed configured with a crates.io upstream. Must be within the current ADO collection.
# NOTE: Azure Artifacts support for Rust is not yet public, but it is enabled for internal ADO organizations.
Expand Down
4 changes: 2 additions & 2 deletions crates/edit/build/i18n.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ pub fn generate(definitions: &str) -> String {
pub enum LocId {{",
);

for (k, _) in translations.iter() {
for k in translations.keys() {
_ = writeln!(out, " {k},");
}

Expand Down Expand Up @@ -187,7 +187,7 @@ const TRANSLATIONS: [[&str; {}]; {}] = [

for lang in &languages {
_ = writeln!(out, " [");
for (_, v) in translations.iter() {
for v in translations.values() {
const DEFAULT: &String = &String::new();
let v = v.get(lang).or_else(|| v.get("en")).unwrap_or(DEFAULT);
_ = writeln!(out, " {v:?},");
Expand Down
39 changes: 12 additions & 27 deletions crates/edit/src/buffer/gap_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,11 @@ impl GapBuffer {
}

fn enlarge_gap(&mut self, len: usize) {
let gap_chunk;
let alloc_chunk;

if matches!(self.buffer, BackingBuffer::VirtualMemory(..)) {
gap_chunk = LARGE_GAP_CHUNK;
alloc_chunk = LARGE_ALLOC_CHUNK;
let (gap_chunk, alloc_chunk) = if matches!(self.buffer, BackingBuffer::VirtualMemory(..)) {
(LARGE_GAP_CHUNK, LARGE_ALLOC_CHUNK)
} else {
gap_chunk = SMALL_GAP_CHUNK;
alloc_chunk = SMALL_ALLOC_CHUNK;
}
(SMALL_GAP_CHUNK, SMALL_ALLOC_CHUNK)
};

let gap_len_old = self.gap_len;
let gap_len_new = (len + gap_chunk + gap_chunk - 1) & !(gap_chunk - 1);
Expand Down Expand Up @@ -333,38 +328,28 @@ impl GapBuffer {
impl ReadableDocument for GapBuffer {
fn read_forward(&self, off: usize) -> &[u8] {
let off = off.min(self.text_length);
let beg;
let len;

if off < self.gap_off {
let (beg, len) = if off < self.gap_off {
// Cursor is before the gap: We can read until the start of the gap.
beg = off;
len = self.gap_off - off;
(off, self.gap_off - off)
} else {
// Cursor is after the gap: We can read until the end of the buffer.
beg = off + self.gap_len;
len = self.text_length - off;
}
(off + self.gap_len, self.text_length - off)
};

unsafe { slice::from_raw_parts(self.text.add(beg).as_ptr(), len) }
}

fn read_backward(&self, off: usize) -> &[u8] {
let off = off.min(self.text_length);
let beg;
let len;

if off <= self.gap_off {
let (beg, len) = if off <= self.gap_off {
// Cursor is before the gap: We can read until the beginning of the buffer.
beg = 0;
len = off;
(0, off)
} else {
// Cursor is after the gap: We can read until the end of the gap.
beg = self.gap_off + self.gap_len;
// The cursor_off doesn't account of the gap_len.
// (This allows us to move the gap without recalculating the cursor position.)
len = off - self.gap_off;
}
(self.gap_off + self.gap_len, off - self.gap_off)
};

unsafe { slice::from_raw_parts(self.text.add(beg).as_ptr(), len) }
}
Expand Down
Loading