Fix different kinds values used for worktree_id (#17523)

This commit is contained in:
Kirill Bulatov 2024-09-07 00:51:09 -04:00 committed by GitHub
parent 47aec5e64d
commit 8985fd87c2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
18 changed files with 136 additions and 127 deletions

View file

@ -6,7 +6,7 @@ mod settings_store;
use gpui::AppContext;
use rust_embed::RustEmbed;
use std::{borrow::Cow, str};
use std::{borrow::Cow, fmt, str};
use util::asset_str;
pub use editable_setting_control::*;
@ -15,6 +15,39 @@ pub use keymap_file::KeymapFile;
pub use settings_file::*;
pub use settings_store::{Settings, SettingsLocation, SettingsSources, SettingsStore};
#[derive(Copy, Clone, PartialEq, Eq, Debug, Hash, PartialOrd, Ord)]
pub struct WorktreeId(usize);
impl From<WorktreeId> for usize {
fn from(value: WorktreeId) -> Self {
value.0
}
}
impl WorktreeId {
pub fn from_usize(handle_id: usize) -> Self {
Self(handle_id)
}
pub fn from_proto(id: u64) -> Self {
Self(id as usize)
}
pub fn to_proto(&self) -> u64 {
self.0 as u64
}
pub fn to_usize(&self) -> usize {
self.0
}
}
impl fmt::Display for WorktreeId {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
std::fmt::Display::fmt(&self.0, f)
}
}
#[derive(RustEmbed)]
#[folder = "../../assets"]
#[include = "settings/*"]