Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GH-7347: Added scroll-lock to the Output view #7570

Merged
merged 1 commit into from
Jun 3, 2020
Merged

Conversation

kittaakos
Copy link
Contributor

@kittaakos kittaakos commented Apr 14, 2020

What it does

  • Adds a scroll-lock to the Output view,
  • Removes the @theia/output dependency from the @theia/languages extension,
  • Replaces the Output view with a monaco editor,
  • Adds context menu to the Output view,
  • Removes the <no output yet> when there is no output on the selected channel,
  • Fixes a runtime error when creating an in-memory (no URI) monaco.editor.ITextModel,
  • Can add decoration via append (previously it was supported with appendLine only),
  • Aligns the OutputChannel API with VS Code (via commands), and
  • Adds quick pick for showing, hiding, and closing and output channel.

How to test

  • You can lock the scrolling in the view,
  • You can use the context menu from the Output view,
  • You can clear the Output view,
  • You can show, hide and close output channels from the Command Palette,
  • Clicking on the tab or in the widget sets the focus properly on the widget. You can see the bluish focus color (with the dark theme) when it's active. Also, there are no warnings due to widget did not activate in the logs ([shell] Widget activation causes a resource leak #7008),
  • You can alter the max output line count from the preferences, the output scales, (set it to e.g. 20)
  • Once you are done with the testing, make sure you dispose one of the output channels (use the Output: Close Output Channel... command), refresh the browser, make a memory snapshot, verify that the previously disposed channel is not in the snapshot.

Feel free using the interim commands for populating the output channels with some dummy inputs:

  • API Sample: Post Date.now() to the 'X' channel.
  • API Sample: Stop Date.now() on 'X' channel.

Closes #7347.
Closes #7008.

Review checklist

Reminder for reviewers

@kittaakos kittaakos force-pushed the output-scroll-lock branch from fdd86b7 to b71c29b Compare April 14, 2020 16:08
@paul-marechal
Copy link
Member

The locked behavior feels weird: in VS Code, it just disables auto-scrolling, but you can still manually scroll around. This implementation prevents me from manually scrolling elsewhere. Is this intended?

@kittaakos kittaakos force-pushed the output-scroll-lock branch 3 times, most recently from 9fd843f to fec6c49 Compare April 15, 2020 15:10
@kittaakos kittaakos marked this pull request as ready for review April 15, 2020 15:16
@kittaakos kittaakos force-pushed the output-scroll-lock branch from fec6c49 to 02067fb Compare April 15, 2020 15:50
Copy link
Contributor Author

@kittaakos kittaakos left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TODOs for me. None of them should affect the functional behavior.

packages/output/src/common/output-channel.ts Outdated Show resolved Hide resolved
packages/output/src/common/output-channel.ts Outdated Show resolved Hide resolved
packages/output/src/common/output-channel.ts Outdated Show resolved Hide resolved
packages/output/src/browser/output-widget.tsx Outdated Show resolved Hide resolved
packages/output/src/browser/output-widget.tsx Outdated Show resolved Hide resolved
packages/output/src/browser/output-widget.tsx Outdated Show resolved Hide resolved
@akosyakov akosyakov added the output issues related to the output label Apr 16, 2020
@kittaakos kittaakos force-pushed the output-scroll-lock branch 3 times, most recently from 93e5264 to d3d20bf Compare April 16, 2020 07:57
@akosyakov
Copy link
Member

akosyakov commented Apr 16, 2020

I see that output content is rendered even if the output widget is not visible. We should not render anything if the output widget is not selected and visible. It will cause performance issues.

EditorConfig is selected, but one and three channels keep rendering:
Screenshot 2020-04-16 at 10 07 34

@kittaakos
Copy link
Contributor Author

I see that output content is rendered even if the output widget is not visible. We should not render anything if the output widget is not selected and visible.

Yes. Otherwise, you cannot keep the scroll-bar.

@akosyakov
Copy link
Member

akosyakov commented Apr 16, 2020

Yes. Otherwise, you cannot keep the scroll-bar.

VS Code does not keep it as well and use only one Monaco editor. I also don't like an idea of having many Monaco editors later. I've seen before in profiling session that text.split(/[\n\r]+/) is hot spot sometimes, i.e. tracing chatty language servers.

@kittaakos
Copy link
Contributor Author

I've seen before in profiling session that text.split(/[\n\r]+/) is hot spot

Yes, but I have not changed that within this PR.

@akosyakov
Copy link
Member

Yes, but I have not changed that within this PR.

On master we never render a channel if it is not selected and visible. With this PR whenever the ouput view is attached all channels get constantly rendered making situation much worse.

Plus if we switch to Monaco editor it forces us to have many instances instead of only one editor which content gets replaced when a channel is switched.

@kittaakos kittaakos force-pushed the output-scroll-lock branch from d3d20bf to 657b25c Compare April 18, 2020 16:02
@kittaakos kittaakos changed the title GH-7347: Added scroll-lock to the Output view [WIP] GH-7347: Added scroll-lock to the Output view Apr 18, 2020
@kittaakos
Copy link
Contributor Author

if we switch to Monaco editor

@akosyakov, I could not pull in the @theia/monaco dependency into @theia/output. Sadly, @theia/languages already depends on @theia/output. There is a cycle. Is it OK to depend on @theia/monaco-editor-core? We can also clean up the dependencies first, then target @theia/monaco instead. Both have their pros and cons. What do you think? Thanks!

@akosyakov
Copy link
Member

Sadly, @theia/languages already depends on @theia/output.

We are going to drop monaco-languageclient then @theia/languages will be removed.

@kittaakos
Copy link
Contributor Author

We are going to drop monaco-languageclient then @theia/languages will be removed.

What should we do before we drop @theia/languages? Thank you!

@paul-marechal
Copy link
Member

paul-marechal commented Apr 20, 2020

There is a bug when I open the output view for the first time, width is too small:

image

It is fixed after switching channels.

Tested on Firefox 75.

@kittaakos
Copy link
Contributor Author

We are going to drop monaco-languageclient then @theia/languages will be removed.

What should we do before we drop @theia/languages? Thank you!

@akosyakov, ping.

@kittaakos
Copy link
Contributor Author

What should we do before we drop @theia/languages? Thank you!

I can create Output commands and invoke them from @theia/languages. It's just a string so no hard dependencies are required. Thoughts?

@kittaakos
Copy link
Contributor Author

create Output commands

We could align the new commands with the current VS Code OutputChannel API.

@akosyakov
Copy link
Member

What should we do before we drop @theia/languages? Thank you!

#7100 It is in plans to work on it next months. cc @svenefftinge @marcdumais-work

@kittaakos kittaakos force-pushed the output-scroll-lock branch from a94e465 to 72fd6c1 Compare May 27, 2020 12:31
@kittaakos kittaakos changed the title [WIP] GH-7347: Added scroll-lock to the Output view GH-7347: Added scroll-lock to the Output view May 27, 2020
@kittaakos
Copy link
Contributor Author

The PR is ready for the review, please see the updated description.

@paul-marechal
Copy link
Member

Only concern I have: Is the Find Command item supposed to be in the Output View context menu?

image

Copy link
Member

@paul-marechal paul-marechal left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code LGTM, tried what you listed under How To Test and everything worked.

packages/output/src/browser/output-widget.tsx Show resolved Hide resolved
@kittaakos
Copy link
Contributor Author

Is the Find Command item supposed to be in the Output View context menu?

Thanks for asking! It's intentional. Actually, I do not mind if it's there or not, I won't ever use it, but I wanted to align the context-menu with VS Code:

Screen Shot 2020-05-27 at 18 38 29

VS Code has it as Comannd Palette..., we call it Find Commands....

I leave the decision to the community.

@lmcbout
Copy link
Contributor

lmcbout commented May 27, 2020

I noticed the context menu on MAC seems different than the one in UBUNTU. I have the same as @marechal-p above.

I vote to keep the command palette.

Note: When I add a new plugins ( vscode-coverage-gutters-2.4.3.vsix) , I noticed that the context menu is modified in VSCode, but the context menu in Theia is not modified.

Note2: I think it would be nice also to have in the context menu an entry: "Copy all" to copy all the data from that output channel or "Select all"

@kittaakos
Copy link
Contributor Author

I noticed the context menu on MAC seems different than the one in UBUNTU. I have the same as @marechal-p above.

FYI: My screenshot was from VS Code, and not Theia.

Note: When I add a new plugins ( vscode-coverage-gutters-2.4.3.vsix) , I noticed that the context menu is modified in VSCode, but the context menu in Theia is not modified.

👍 Feel free to open a feature request for it.

Note2: I think it would be nice also to have in the context menu an entry: "Copy all" to copy all the data from that output channel or "Select all"

Sounds great, can you please file a feature request so that we won't forget to implement it. Thanks!

Copy link
Contributor

@lmcbout lmcbout left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

New issues ( #7911 and #7912 ) added according to the features request
Works fine, tested on UBUNTU 18.04 and Chrome
Thanks @kittaakos

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm uncomfortable with many new contribution points introduced to satisfy a single use case. Usually we need at least 3 to generalize something. I added comments with proposals how to simplify new concepts.

packages/monaco/src/browser/monaco-editor-model.ts Outdated Show resolved Hide resolved
packages/monaco/src/browser/monaco-editor-provider.ts Outdated Show resolved Hide resolved
@kittaakos kittaakos force-pushed the output-scroll-lock branch from 72fd6c1 to 928adf4 Compare June 2, 2020 12:18

createModel(
resource: Resource,
m2p: MonacoToProtocolConverter,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need to pass converters. They can be injected by subclasses. Or we can convert interface to abstract class to replace interface + symbol and inject converters for all subclasses.

return false;
open(uri: URI, options?: OpenerOptions): Promise<OutputWidget> {
return new Promise<OutputWidget>((resolve, reject) => {
if (!OutputUri.is(uri)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not to use async/await? this method will hang if something goes wrong in openView or setInptu

Copy link
Member

@akosyakov akosyakov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wow, that's a great improvement to the output view!

@akosyakov
Copy link
Member

@kittaakos does it resolves #2702 and #2385 as well?

@kittaakos kittaakos force-pushed the output-scroll-lock branch from 928adf4 to acb7be7 Compare June 3, 2020 09:25
Closes #7347.
Closes #7008.

Signed-off-by: Akos Kitta <kittaakos@typefox.io>
@kittaakos kittaakos force-pushed the output-scroll-lock branch from acb7be7 to 7048b1a Compare June 3, 2020 09:41
@kittaakos
Copy link
Contributor Author

Thank you all for the review!

Comment on lines +240 to +251
class NoopDragOverDockPanel extends DockPanel {

constructor(options?: DockPanel.IOptions) {
super(options);
NoopDragOverDockPanel.prototype['_evtDragOver'] = (event: IDragEvent) => {
event.preventDefault();
event.stopPropagation();
event.dropAction = 'none';
};
}

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kittaakos, it looks like this code is responsible for #10932. Do you recall the motivation for making the Output view undroppable?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for taking care of this!

it looks like this code is responsible for #10932.

Do you want to have the same behavior as the Problem view? Split the view like this:

other_widget.mp4

It is not possible with the Output view; it's a bug.

The main reason I used a custom panel implementation was to avoid dropping an editor into the panel. Like this:

output.mp4

I hope this helps. Let me know if there is anything I can assist you with fixing this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the screen casts; they help clarify things quite a bit. I didn't realize the Output widget behaved as a panel with each of the channels as a child widget. I think it would be nice if the Output view could allow drops as other widgets do, to either place the new widget on the bottom tabbar or split the bottom pane. Otherwise, it feels like a bug, even though it's deliberate, since it isn't clear to users why the Output widget would be different from other widgets in this respect.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like something like this might do the trick:

/**
 * Customized `DockPanel` that does not allow dropping widgets into it.
 * Intercepts `'p-dragover'` events, and sets the desired drop action to `'none'`.
 */
class NoopDragOverDockPanel extends DockPanel { }
const noop = () => { };
NoopDragOverDockPanel.prototype['_evtDragOver'] = noop;
NoopDragOverDockPanel.prototype['_evtDrop'] = noop;
NoopDragOverDockPanel.prototype['_evtDragLeave'] = noop;

By preventing the Output widget from handling any of those events, we pass them up to the bottom pane dock panel and allow it to handle them. What do you think of that?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
output issues related to the output
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[output] Implement output scroll-lock [shell] Widget activation causes a resource leak
6 participants