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
1 change: 0 additions & 1 deletion crates/edit/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ features = [
"Win32_Security",
"Win32_Storage_FileSystem",
"Win32_System_Console",
"Win32_System_Diagnostics_Debug",
"Win32_System_IO",
"Win32_System_LibraryLoader",
"Win32_System_Threading",
Expand Down
51 changes: 0 additions & 51 deletions crates/edit/src/apperr.rs

This file was deleted.

11 changes: 6 additions & 5 deletions crates/edit/src/bin/edit/documents.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,15 @@

use std::collections::LinkedList;
use std::ffi::OsStr;
use std::fs;
use std::fs::File;
use std::path::{Path, PathBuf};
use std::{fs, io};

use edit::buffer::{RcTextBuffer, TextBuffer};
use edit::helpers::{CoordType, Point};
use edit::{apperr, path, sys};
use edit::{path, sys};

use crate::apperr;
use crate::state::DisplayablePathBuf;

pub struct Document {
Expand Down Expand Up @@ -144,10 +145,10 @@ impl DocumentManager {
let (path, goto) = Self::parse_filename_goto(path);
let path = path::normalize(path);

let mut file = match Self::open_for_reading(&path) {
let mut file = match File::open(&path) {
Ok(file) => Some(file),
Err(err) if sys::apperr_is_not_found(err) => None,
Err(err) => return Err(err),
Err(err) if err.kind() == io::ErrorKind::NotFound => None,
Err(err) => return Err(err.into()),
};

let file_id = if file.is_some() { Some(sys::file_id(file.as_ref(), &path)?) } else { None };
Expand Down
2 changes: 1 addition & 1 deletion crates/edit/src/bin/edit/draw_editor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn draw_editor(ctx: &mut Context, state: &mut State) {

fn draw_search(ctx: &mut Context, state: &mut State) {
if let Err(err) = icu::init() {
error_log_add(ctx, state, err);
error_log_add(ctx, state, err.into());
state.wants_search.kind = StateSearchKind::Disabled;
return;
}
Expand Down
2 changes: 1 addition & 1 deletion crates/edit/src/bin/edit/draw_filepicker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,7 @@ fn draw_dialog_saveas_refresh_files(state: &mut State) {
}

for entries in &mut dirs_files[1..] {
entries.sort_by(|a, b| {
entries.sort_unstable_by(|a, b| {
let a = a.as_bytes();
let b = b.as_bytes();

Expand Down
2 changes: 1 addition & 1 deletion crates/edit/src/bin/edit/draw_statusbar.rs
Original file line number Diff line number Diff line change
Expand Up @@ -302,7 +302,7 @@ fn encoding_picker_update_list(state: &mut State) {
}
}

matches.sort_by(|a, b| b.0.cmp(&a.0));
matches.sort_unstable_by(|a, b| b.0.cmp(&a.0));
state.encoding_picker_results = Some(Vec::from_iter(matches.iter().map(|(_, enc)| *enc)));
}

Expand Down
2 changes: 1 addition & 1 deletion crates/edit/src/bin/edit/localization.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
// Copyright (c) Microsoft Corporation.
// Licensed under the MIT License.

use edit::helpers::AsciiStringHelpers;
use edit::sys;
use stdext::AsciiStringHelpers as _;
use stdext::arena::scratch_arena;

include!(concat!(env!("OUT_DIR"), "/i18n_edit.rs"));
Expand Down
6 changes: 5 additions & 1 deletion crates/edit/src/bin/edit/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

#![feature(allocator_api, linked_list_cursors, string_from_utf8_lossy_owned)]

mod apperr;
mod documents;
mod draw_editor;
mod draw_filepicker;
Expand All @@ -26,7 +27,7 @@ use edit::input::{self, kbmod, vk};
use edit::oklab::StraightRgba;
use edit::tui::*;
use edit::vt::{self, Token};
use edit::{apperr, base64, path, sys, unicode};
use edit::{base64, path, sys, unicode};
use localization::*;
use state::*;
use stdext::arena::{self, Arena, ArenaString, scratch_arena};
Expand All @@ -37,6 +38,9 @@ const SCRATCH_ARENA_CAPACITY: usize = 128 * MEBI;
#[cfg(target_pointer_width = "64")]
const SCRATCH_ARENA_CAPACITY: usize = 512 * MEBI;

// NOTE: Before our main() gets called, Rust initializes its stdlib. This pulls in the entire
// std::io::{stdin, stdout, stderr} machinery, and probably some more, which amounts to about 20KB.
// It can technically be avoided nowadays with `#![no_main]`. Maybe a fun project for later? :)
fn main() -> process::ExitCode {
if cfg!(debug_assertions) {
let hook = std::panic::take_hook();
Expand Down
10 changes: 5 additions & 5 deletions crates/edit/src/bin/edit/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,9 @@ use edit::framebuffer::IndexedColor;
use edit::helpers::*;
use edit::oklab::StraightRgba;
use edit::tui::*;
use edit::{apperr, buffer, icu, sys};
use edit::{buffer, icu};

use crate::apperr;
use crate::documents::DocumentManager;
use crate::localization::*;

Expand All @@ -27,10 +28,9 @@ impl From<apperr::Error> for FormatApperr {
impl std::fmt::Display for FormatApperr {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self.0 {
apperr::APP_ICU_MISSING => f.write_str(loc(LocId::ErrorIcuMissing)),
apperr::Error::App(code) => write!(f, "Unknown app error code: {code}"),
apperr::Error::Icu(code) => icu::apperr_format(f, code),
apperr::Error::Sys(code) => sys::apperr_format(f, code),
apperr::Error::Icu(icu::ICU_MISSING_ERROR) => f.write_str(loc(LocId::ErrorIcuMissing)),
apperr::Error::Icu(ref err) => err.fmt(f),
apperr::Error::Io(ref err) => err.fmt(f),
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions crates/edit/src/buffer/gap_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

use std::ops::Range;
use std::ptr::{self, NonNull};
use std::slice;
use std::{io, slice};

use stdext::sys::{virtual_commit, virtual_release, virtual_reserve};
use stdext::{ReplaceRange as _, slice_copy_safe};

use crate::apperr;
use crate::document::{ReadableDocument, WriteableDocument};
use crate::helpers::*;

Expand Down Expand Up @@ -64,7 +64,7 @@ pub struct GapBuffer {
}

impl GapBuffer {
pub fn new(small: bool) -> apperr::Result<Self> {
pub fn new(small: bool) -> io::Result<Self> {
let reserve;
let buffer;
let text;
Expand Down
Loading