Show formatting failure (#9229)
This fixes #8072 and #9061 by surfacing formatting errors in the activity indicator. It shows a message in the activity indicator if the last attempt to format a buffer failed. It only keeps track of the last attempt, so any further formatting that succeeds will reset or update the error message. I chose to only keep track of that, because everything else (keeping track of formatting state per buffer, per project, per worktree) seems complicated with little benefit, since we'd have to keep track of that state, update it, clean it, etc. We can still do that should we decide that we need to keep track of the state on a per-buffer basis, but I think for now this is a good, simple solution. This also changes the `OpenLog` action to scroll to the end of the buffer and to not mark the buffer as dirty. Release Notes: - Added message to activity indicator if last attempt to format a buffer failed. Message will get reset when next formatting succeeds. Clicking on message opens log with more information. ([#8072](https://github.com/zed-industries/zed/issues/8072) and [#9061](https://github.com/zed-industries/zed/issues/9061)). - Changed `zed: Open Log` action to not mark the opened log file as dirty and to always scroll to the bottom of the log. https://github.com/zed-industries/zed/assets/1185253/951fb9ac-8b8b-483a-a46d-712e52878a4d
This commit is contained in:
parent
39a0841ea8
commit
8c87b349dc
4 changed files with 334 additions and 290 deletions
|
@ -7,7 +7,7 @@ use assistant::AssistantPanel;
|
|||
use breadcrumbs::Breadcrumbs;
|
||||
use client::ZED_URL_SCHEME;
|
||||
use collections::VecDeque;
|
||||
use editor::{Editor, MultiBuffer};
|
||||
use editor::{scroll::Autoscroll, Editor, MultiBuffer};
|
||||
use gpui::{
|
||||
actions, point, px, AppContext, AsyncAppContext, Context, FocusableView, PromptLevel,
|
||||
TitlebarOptions, View, ViewContext, VisualContext, WindowBounds, WindowKind, WindowOptions,
|
||||
|
@ -41,7 +41,7 @@ use vim::VimModeSetting;
|
|||
use welcome::BaseKeymap;
|
||||
use workspace::{
|
||||
create_and_open_local_file, notifications::simple_message_notification::MessageNotification,
|
||||
open_new, AppState, NewFile, NewWindow, Toast, Workspace, WorkspaceSettings,
|
||||
open_new, AppState, NewFile, NewWindow, OpenLog, Toast, Workspace, WorkspaceSettings,
|
||||
};
|
||||
use workspace::{notifications::DetachAndPromptErr, Pane};
|
||||
use zed_actions::{OpenBrowser, OpenSettings, OpenZedUrl, Quit};
|
||||
|
@ -62,7 +62,6 @@ actions!(
|
|||
OpenLicenses,
|
||||
OpenLocalSettings,
|
||||
OpenLocalTasks,
|
||||
OpenLog,
|
||||
OpenTasks,
|
||||
OpenTelemetryLog,
|
||||
ResetBufferFontSize,
|
||||
|
@ -561,21 +560,25 @@ fn open_log_file(workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
|
|||
};
|
||||
let project = workspace.project().clone();
|
||||
let buffer = project
|
||||
.update(cx, |project, cx| project.create_buffer("", None, cx))
|
||||
.update(cx, |project, cx| project.create_buffer(&log, None, cx))
|
||||
.expect("creating buffers on a local workspace always succeeds");
|
||||
buffer.update(cx, |buffer, cx| buffer.edit([(0..0, log)], None, cx));
|
||||
|
||||
let buffer = cx.new_model(|cx| {
|
||||
MultiBuffer::singleton(buffer, cx).with_title("Log".into())
|
||||
});
|
||||
workspace.add_item_to_active_pane(
|
||||
Box::new(
|
||||
cx.new_view(|cx| {
|
||||
Editor::for_multibuffer(buffer, Some(project), cx)
|
||||
}),
|
||||
),
|
||||
cx,
|
||||
);
|
||||
let editor =
|
||||
cx.new_view(|cx| Editor::for_multibuffer(buffer, Some(project), cx));
|
||||
|
||||
editor.update(cx, |editor, cx| {
|
||||
let last_multi_buffer_offset = editor.buffer().read(cx).len(cx);
|
||||
editor.change_selections(Some(Autoscroll::fit()), cx, |s| {
|
||||
s.select_ranges(Some(
|
||||
last_multi_buffer_offset..last_multi_buffer_offset,
|
||||
));
|
||||
})
|
||||
});
|
||||
|
||||
workspace.add_item_to_active_pane(Box::new(editor), cx);
|
||||
})
|
||||
.log_err();
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue