Merge branch 'main' into markdown-fenced-blocks
This commit is contained in:
commit
dff08d3cfe
81 changed files with 823 additions and 171 deletions
|
@ -1,50 +0,0 @@
|
|||
use crate::OpenBrowser;
|
||||
use gpui::{
|
||||
elements::{MouseEventHandler, Text},
|
||||
platform::CursorStyle,
|
||||
Element, Entity, MouseButton, RenderContext, View,
|
||||
};
|
||||
use settings::Settings;
|
||||
use workspace::{item::ItemHandle, StatusItemView};
|
||||
|
||||
pub const NEW_ISSUE_URL: &str = "https://github.com/zed-industries/feedback/issues/new/choose";
|
||||
|
||||
pub struct FeedbackLink;
|
||||
|
||||
impl Entity for FeedbackLink {
|
||||
type Event = ();
|
||||
}
|
||||
|
||||
impl View for FeedbackLink {
|
||||
fn ui_name() -> &'static str {
|
||||
"FeedbackLink"
|
||||
}
|
||||
|
||||
fn render(&mut self, cx: &mut RenderContext<'_, Self>) -> gpui::ElementBox {
|
||||
MouseEventHandler::<Self>::new(0, cx, |state, cx| {
|
||||
let theme = &cx.global::<Settings>().theme;
|
||||
let theme = &theme.workspace.status_bar.feedback;
|
||||
Text::new(
|
||||
"Give Feedback".to_string(),
|
||||
theme.style_for(state, false).clone(),
|
||||
)
|
||||
.boxed()
|
||||
})
|
||||
.with_cursor_style(CursorStyle::PointingHand)
|
||||
.on_click(MouseButton::Left, |_, cx| {
|
||||
cx.dispatch_action(OpenBrowser {
|
||||
url: NEW_ISSUE_URL.into(),
|
||||
})
|
||||
})
|
||||
.boxed()
|
||||
}
|
||||
}
|
||||
|
||||
impl StatusItemView for FeedbackLink {
|
||||
fn set_active_pane_item(
|
||||
&mut self,
|
||||
_: Option<&dyn ItemHandle>,
|
||||
_: &mut gpui::ViewContext<Self>,
|
||||
) {
|
||||
}
|
||||
}
|
|
@ -14,6 +14,7 @@ use client::{
|
|||
http::{self, HttpClient},
|
||||
UserStore, ZED_SECRET_CLIENT_TOKEN,
|
||||
};
|
||||
|
||||
use futures::{
|
||||
channel::{mpsc, oneshot},
|
||||
FutureExt, SinkExt, StreamExt,
|
||||
|
@ -125,11 +126,14 @@ fn main() {
|
|||
|
||||
watch_keymap_file(keymap_file, cx);
|
||||
|
||||
cx.set_global(client.clone());
|
||||
|
||||
context_menu::init(cx);
|
||||
project::Project::init(&client);
|
||||
client::init(client.clone(), cx);
|
||||
command_palette::init(cx);
|
||||
editor::init(cx);
|
||||
feedback::init(cx);
|
||||
go_to_line::init(cx);
|
||||
file_finder::init(cx);
|
||||
outline::init(cx);
|
||||
|
|
|
@ -340,15 +340,15 @@ pub fn menus() -> Vec<Menu<'static>> {
|
|||
MenuItem::Separator,
|
||||
MenuItem::Action {
|
||||
name: "Copy System Specs Into Clipboard",
|
||||
action: Box::new(crate::CopySystemSpecsIntoClipboard),
|
||||
action: Box::new(feedback::CopySystemSpecsIntoClipboard),
|
||||
},
|
||||
MenuItem::Action {
|
||||
name: "File Bug Report",
|
||||
action: Box::new(crate::FileBugReport),
|
||||
action: Box::new(feedback::FileBugReport),
|
||||
},
|
||||
MenuItem::Action {
|
||||
name: "Request Feature",
|
||||
action: Box::new(crate::RequestFeature),
|
||||
action: Box::new(feedback::RequestFeature),
|
||||
},
|
||||
MenuItem::Separator,
|
||||
MenuItem::Action {
|
||||
|
|
|
@ -1,52 +0,0 @@
|
|||
use std::{env, fmt::Display};
|
||||
|
||||
use gpui::AppContext;
|
||||
use human_bytes::human_bytes;
|
||||
use sysinfo::{System, SystemExt};
|
||||
use util::channel::ReleaseChannel;
|
||||
|
||||
pub struct SystemSpecs {
|
||||
app_version: &'static str,
|
||||
release_channel: &'static str,
|
||||
os_name: &'static str,
|
||||
os_version: Option<String>,
|
||||
memory: u64,
|
||||
architecture: &'static str,
|
||||
}
|
||||
|
||||
impl SystemSpecs {
|
||||
pub fn new(cx: &AppContext) -> Self {
|
||||
let platform = cx.platform();
|
||||
let system = System::new_all();
|
||||
|
||||
SystemSpecs {
|
||||
app_version: env!("CARGO_PKG_VERSION"),
|
||||
release_channel: cx.global::<ReleaseChannel>().dev_name(),
|
||||
os_name: platform.os_name(),
|
||||
os_version: platform
|
||||
.os_version()
|
||||
.ok()
|
||||
.map(|os_version| os_version.to_string()),
|
||||
memory: system.total_memory(),
|
||||
architecture: env::consts::ARCH,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Display for SystemSpecs {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
let os_information = match &self.os_version {
|
||||
Some(os_version) => format!("OS: {} {}", self.os_name, os_version),
|
||||
None => format!("OS: {}", self.os_name),
|
||||
};
|
||||
let system_specs = [
|
||||
format!("Zed: {} ({})", self.app_version, self.release_channel),
|
||||
os_information,
|
||||
format!("Memory: {}", human_bytes(self.memory as f64)),
|
||||
format!("Architecture: {}", self.architecture),
|
||||
]
|
||||
.join("\n");
|
||||
|
||||
write!(f, "{system_specs}")
|
||||
}
|
||||
}
|
|
@ -1,10 +1,7 @@
|
|||
mod feedback;
|
||||
pub mod languages;
|
||||
pub mod menus;
|
||||
pub mod system_specs;
|
||||
#[cfg(any(test, feature = "test-support"))]
|
||||
pub mod test;
|
||||
|
||||
use anyhow::{anyhow, Context, Result};
|
||||
use assets::Assets;
|
||||
use breadcrumbs::Breadcrumbs;
|
||||
|
@ -23,8 +20,7 @@ use gpui::{
|
|||
},
|
||||
impl_actions,
|
||||
platform::{WindowBounds, WindowOptions},
|
||||
AssetSource, AsyncAppContext, ClipboardItem, PromptLevel, TitlebarOptions, ViewContext,
|
||||
WindowKind,
|
||||
AssetSource, AsyncAppContext, PromptLevel, TitlebarOptions, ViewContext, WindowKind,
|
||||
};
|
||||
use language::Rope;
|
||||
use lazy_static::lazy_static;
|
||||
|
@ -35,14 +31,13 @@ use search::{BufferSearchBar, ProjectSearchBar};
|
|||
use serde::Deserialize;
|
||||
use serde_json::to_string_pretty;
|
||||
use settings::{keymap_file_json_schema, settings_file_json_schema, Settings};
|
||||
use std::{env, path::Path, str, sync::Arc};
|
||||
use system_specs::SystemSpecs;
|
||||
use std::{borrow::Cow, env, path::Path, str, sync::Arc};
|
||||
use util::{channel::ReleaseChannel, paths, ResultExt};
|
||||
pub use workspace;
|
||||
use workspace::{sidebar::SidebarSide, AppState, Workspace};
|
||||
|
||||
#[derive(Deserialize, Clone, PartialEq)]
|
||||
struct OpenBrowser {
|
||||
pub struct OpenBrowser {
|
||||
url: Arc<str>,
|
||||
}
|
||||
|
||||
|
@ -62,6 +57,7 @@ actions!(
|
|||
DebugElements,
|
||||
OpenSettings,
|
||||
OpenLog,
|
||||
OpenLicenses,
|
||||
OpenTelemetryLog,
|
||||
OpenKeymap,
|
||||
OpenDefaultSettings,
|
||||
|
@ -71,9 +67,6 @@ actions!(
|
|||
ResetBufferFontSize,
|
||||
InstallCommandLineInterface,
|
||||
ResetDatabase,
|
||||
CopySystemSpecsIntoClipboard,
|
||||
RequestFeature,
|
||||
FileBugReport
|
||||
]
|
||||
);
|
||||
|
||||
|
@ -184,6 +177,19 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
|||
open_log_file(workspace, app_state.clone(), cx);
|
||||
}
|
||||
});
|
||||
cx.add_action({
|
||||
let app_state = app_state.clone();
|
||||
move |workspace: &mut Workspace, _: &OpenLicenses, cx: &mut ViewContext<Workspace>| {
|
||||
open_bundled_file(
|
||||
workspace,
|
||||
app_state.clone(),
|
||||
"licenses.md",
|
||||
"Open Source License Attribution",
|
||||
"Markdown",
|
||||
cx,
|
||||
);
|
||||
}
|
||||
});
|
||||
cx.add_action({
|
||||
let app_state = app_state.clone();
|
||||
move |workspace: &mut Workspace, _: &OpenTelemetryLog, cx: &mut ViewContext<Workspace>| {
|
||||
|
@ -199,11 +205,12 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
|||
cx.add_action({
|
||||
let app_state = app_state.clone();
|
||||
move |workspace: &mut Workspace, _: &OpenDefaultKeymap, cx: &mut ViewContext<Workspace>| {
|
||||
open_bundled_config_file(
|
||||
open_bundled_file(
|
||||
workspace,
|
||||
app_state.clone(),
|
||||
"keymaps/default.json",
|
||||
"Default Key Bindings",
|
||||
"JSON",
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
@ -213,11 +220,12 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
|||
move |workspace: &mut Workspace,
|
||||
_: &OpenDefaultSettings,
|
||||
cx: &mut ViewContext<Workspace>| {
|
||||
open_bundled_config_file(
|
||||
open_bundled_file(
|
||||
workspace,
|
||||
app_state.clone(),
|
||||
"settings/default.json",
|
||||
"Default Settings",
|
||||
"JSON",
|
||||
cx,
|
||||
);
|
||||
}
|
||||
|
@ -256,41 +264,6 @@ pub fn init(app_state: &Arc<AppState>, cx: &mut gpui::MutableAppContext) {
|
|||
},
|
||||
);
|
||||
|
||||
cx.add_action(
|
||||
|_: &mut Workspace, _: &CopySystemSpecsIntoClipboard, cx: &mut ViewContext<Workspace>| {
|
||||
let system_specs = SystemSpecs::new(cx).to_string();
|
||||
let item = ClipboardItem::new(system_specs.clone());
|
||||
cx.prompt(
|
||||
gpui::PromptLevel::Info,
|
||||
&format!("Copied into clipboard:\n\n{system_specs}"),
|
||||
&["OK"],
|
||||
);
|
||||
cx.write_to_clipboard(item);
|
||||
},
|
||||
);
|
||||
|
||||
cx.add_action(
|
||||
|_: &mut Workspace, _: &RequestFeature, cx: &mut ViewContext<Workspace>| {
|
||||
let url = "https://github.com/zed-industries/feedback/issues/new?assignees=&labels=enhancement%2Ctriage&template=0_feature_request.yml";
|
||||
cx.dispatch_action(OpenBrowser {
|
||||
url: url.into(),
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
cx.add_action(
|
||||
|_: &mut Workspace, _: &FileBugReport, cx: &mut ViewContext<Workspace>| {
|
||||
let system_specs_text = SystemSpecs::new(cx).to_string();
|
||||
let url = format!(
|
||||
"https://github.com/zed-industries/feedback/issues/new?assignees=&labels=defect%2Ctriage&template=2_bug_report.yml&environment={}",
|
||||
urlencoding::encode(&system_specs_text)
|
||||
);
|
||||
cx.dispatch_action(OpenBrowser {
|
||||
url: url.into(),
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
activity_indicator::init(cx);
|
||||
call::init(app_state.client.clone(), app_state.user_store.clone(), cx);
|
||||
settings::KeymapFileContent::load_defaults(cx);
|
||||
|
@ -375,12 +348,12 @@ pub fn initialize_workspace(
|
|||
let activity_indicator =
|
||||
activity_indicator::ActivityIndicator::new(workspace, app_state.languages.clone(), cx);
|
||||
let cursor_position = cx.add_view(|_| editor::items::CursorPosition::new());
|
||||
let feedback_link = cx.add_view(|_| feedback::FeedbackLink);
|
||||
let feedback_button = cx.add_view(|_| feedback::feedback_editor::FeedbackButton {});
|
||||
workspace.status_bar().update(cx, |status_bar, cx| {
|
||||
status_bar.add_left_item(diagnostic_summary, cx);
|
||||
status_bar.add_left_item(activity_indicator, cx);
|
||||
status_bar.add_right_item(cursor_position, cx);
|
||||
status_bar.add_right_item(feedback_link, cx);
|
||||
status_bar.add_right_item(feedback_button, cx);
|
||||
});
|
||||
|
||||
auto_update::notify_of_any_new_update(cx.weak_handle(), cx);
|
||||
|
@ -660,21 +633,24 @@ fn open_telemetry_log_file(
|
|||
}).detach();
|
||||
}
|
||||
|
||||
fn open_bundled_config_file(
|
||||
fn open_bundled_file(
|
||||
workspace: &mut Workspace,
|
||||
app_state: Arc<AppState>,
|
||||
asset_path: &'static str,
|
||||
title: &'static str,
|
||||
language: &'static str,
|
||||
cx: &mut ViewContext<Workspace>,
|
||||
) {
|
||||
workspace
|
||||
.with_local_workspace(&app_state, cx, |workspace, cx| {
|
||||
let project = workspace.project().clone();
|
||||
let buffer = project.update(cx, |project, cx| {
|
||||
let text = Assets::get(asset_path).unwrap().data;
|
||||
let text = Assets::get(asset_path)
|
||||
.map(|f| f.data)
|
||||
.unwrap_or_else(|| Cow::Borrowed(b"File not found"));
|
||||
let text = str::from_utf8(text.as_ref()).unwrap();
|
||||
project
|
||||
.create_buffer(text, project.languages().language_for_name("JSON"), cx)
|
||||
.create_buffer(text, project.languages().language_for_name(language), cx)
|
||||
.expect("creating buffers on a local workspace always succeeds")
|
||||
});
|
||||
let buffer =
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue