Skip to content

Commit

Permalink
feat(ux): Move search to sidebar (#2415)
Browse files Browse the repository at this point in the history
In starting to work on #528 - vim navigation for the file explorer (and other bits of UI, like search, SCM, etc) - there's some preliminary work that needs to happen. In particular, we need to refine our concept of 'Focus' - for example, we currently have 'Explorer' as a focus state, but as we break down #528 and look at features like #1785 (directory explorers) - we need to refine this. In particular, there could multiple 'explorers' in the view, and the focus might need some state along with - like the current selected item, information about the viewport (for `zz`, etc).

We'll need to 'fractalize' our focus state - we'll keep track of sort of the high-level place we have focus - for example, the `Sidebar`, and then from there, the `Sidebar` can route focus operations, like text-input and paste, to the appropriate piece, which can then delegate it further (for example, for search - one focus state will be input focus, and another will be navigating the search results). So just like we have a 'fractal' model for state - we'll need a 'fractal' model for focus to handle these cases.

In addition, a common request I get (mentioned in #1914, and comes up a lot in e-mail) is that the search behavior right now is confusing - all other buttons in the sidebar change the sidebar stop, but the search one opens up an extra pane. Since we can now resize the search pane, and it will simplify the focus-work described above (it would otherwise be a special case), figured it was a good to move it. The UX should still be improved - with the default sidebar size, it's difficult to interpret the results.

__TODO:__
- [x] Fix context menu behavior in new model - there are some cases where it stays open
- [x] Fix default focus for search / SCM / extensions
  • Loading branch information
bryphe authored Sep 9, 2020
1 parent a0bbd2d commit 881839e
Show file tree
Hide file tree
Showing 26 changed files with 496 additions and 469 deletions.
71 changes: 71 additions & 0 deletions src/Feature/LanguageSupport/Diagnostics.re
Original file line number Diff line number Diff line change
Expand Up @@ -161,3 +161,74 @@ let getDiagnosticsAtPosition = (instance, buffer, position) => {
let getDiagnosticsMap = (instance, buffer) => {
getDiagnostics(instance, buffer) |> _explodeDiagnostics(buffer);
};

module View = {
open Revery.UI;
open Oni_Components;

module Colors = Feature_Theme.Colors;

module Styles = {
open Style;

let pane = [flexGrow(1), flexDirection(`Row)];

let noResultsContainer = [
flexGrow(1),
alignItems(`Center),
justifyContent(`Center),
];

let title = (~theme) => [
color(Colors.PanelTitle.activeForeground.from(theme)),
margin(8),
];
};

let toLocListItem = (diagWithUri: (Uri.t, Diagnostic.t)) => {
let (uri, diag) = diagWithUri;
let file = Uri.toFileSystemPath(uri);
let location = Diagnostic.(diag.range.start);
LocationList.{file, location, text: diag.message, highlight: None};
};
let make =
(
~onSelectFile:
(
~filePath: string,
~position: EditorCoreTypes.CharacterPosition.t
) =>
unit,
~diagnostics,
~theme,
~uiFont: UiFont.t,
~editorFont,
(),
) => {
let items =
diagnostics
|> getAllDiagnostics
|> List.map(toLocListItem)
|> Array.of_list;

let onSelectItem = (item: LocationList.item) => {
onSelectFile(~filePath=item.file, ~position=item.location);
};

let innerElement =
if (Array.length(items) == 0) {
<View style=Styles.noResultsContainer>
<Text
style={Styles.title(~theme)}
fontFamily={uiFont.family}
fontSize={uiFont.size}
text="No problems, yet!"
/>
</View>;
} else {
<LocationList theme uiFont editorFont items onSelectItem />;
};

<View style=Styles.pane> innerElement </View>;
};
};
17 changes: 17 additions & 0 deletions src/Feature/LanguageSupport/Diagnostics.rei
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,20 @@ let getDiagnosticsAtPosition:
let getDiagnosticsMap: (t, Buffer.t) => IntMap.t(list(Diagnostic.t));

let getAllDiagnostics: t => list((Uri.t, Diagnostic.t));

module View: {
let make:
(
~onSelectFile: (
~filePath: string,
~position: EditorCoreTypes.CharacterPosition.t
) =>
unit,
~diagnostics: t,
~theme: ColorTheme.Colors.t,
~uiFont: UiFont.t,
~editorFont: Service_Font.font,
unit
) =>
Revery.UI.element;
};
10 changes: 1 addition & 9 deletions src/Feature/Notification/Feature_Notification.re
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,12 @@ let initial = [];
[@deriving show({with_path: false})]
type msg =
| Created(notification)
| Dismissed(notification)
| AllDismissed;
| Dismissed(notification);

let update = (model, msg) => {
switch (msg) {
| Created(item) => [item, ...model]
| Dismissed(item) => List.filter(it => it.id != item.id, model)
| AllDismissed => initial
};
};

Expand All @@ -69,12 +67,6 @@ module Effects = {
Isolinear.Effect.createWithDispatch(~name="notification.dismiss", dispatch =>
dispatch(Dismissed(notification))
);

let dismissAll =
Isolinear.Effect.createWithDispatch(
~name="notification.dismissAll", dispatch =>
dispatch(AllDismissed)
);
};

// COLORS
Expand Down
1 change: 0 additions & 1 deletion src/Feature/Notification/Feature_Notification.rei
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module Effects: {
let create:
(~kind: kind=?, ~source: string=?, string) => Isolinear.Effect.t(msg);
let dismiss: notification => Isolinear.Effect.t(msg);
let dismissAll: Isolinear.Effect.t(msg);
};

// COLORS
Expand Down
Loading

0 comments on commit 881839e

Please sign in to comment.