Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,11 @@ export class ClickLinkMouseEvent {
public readonly hasTriggerModifier: boolean;
public readonly hasSideBySideModifier: boolean;
public readonly isNoneOrSingleMouseDown: boolean;
public readonly hasRightClick: boolean;

constructor(source: IEditorMouseEvent, opts: ClickLinkOptions) {
this.target = source.target;
this.hasRightClick = source.event.rightButton;
this.hasTriggerModifier = hasModifier(source.event, opts.triggerModifier);
this.hasSideBySideModifier = hasModifier(source.event, opts.triggerSideBySideModifier);
this.isNoneOrSingleMouseDown = (source.event.detail <= 1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export class ToggleStickyScroll extends Action2 {
menu: [
{ id: MenuId.CommandPalette },
{ id: MenuId.MenubarViewMenu, group: '5_editor', order: 6 },
{ id: MenuId.StickyScrollContext }
]
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ import { StickyScrollWidget, StickyScrollWidgetState } from './stickyScrollWidge
import { StickyLineCandidateProvider, StickyRange } from './stickyScrollProvider';
import { IModelTokensChangedEvent } from 'vs/editor/common/textModelEvents';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import * as dom from 'vs/base/browser/dom';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { MenuId } from 'vs/platform/actions/common/actions';

export class StickyScrollController extends Disposable implements IEditorContribution {

Expand All @@ -26,6 +29,7 @@ export class StickyScrollController extends Disposable implements IEditorContrib
_editor: ICodeEditor,
@ILanguageFeaturesService _languageFeaturesService: ILanguageFeaturesService,
@IInstantiationService _instaService: IInstantiationService,
@IContextMenuService private readonly _contextMenuService: IContextMenuService,
) {
super();
this._editor = _editor;
Expand All @@ -41,6 +45,9 @@ export class StickyScrollController extends Disposable implements IEditorContrib
}
}));
this.readConfiguration();
this._register(dom.addDisposableListener(this._stickyScrollWidget.getDomNode(), dom.EventType.CONTEXT_MENU, async (event: MouseEvent) => {
this.onContextMenu(event);
}));
}

public get stickyScrollCandidateProvider() {
Expand All @@ -51,6 +58,13 @@ export class StickyScrollController extends Disposable implements IEditorContrib
return this._widgetState;
}

private onContextMenu(event: MouseEvent) {
this._contextMenuService.showContextMenu({
menuId: MenuId.StickyScrollContext,
getAnchor: () => event,
});
}

private readConfiguration() {
const options = this._editor.getOption(EditorOption.stickyScroll);
if (options.enabled === false) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export class StickyScrollWidget extends Disposable implements IOverlayWidget {
this._editor.revealPosition({ lineNumber: this._hoverOnLine, column: 1 });
}
this._instaService.invokeFunction(goToDefinitionWithLocation, e, this._editor as IActiveCodeEditor, { uri: this._editor.getModel()!.uri, range: this._stickyRangeProjectedOnEditor } as Location);
} else {
} else if (!e.hasRightClick) {
// Normal click
this._editor.revealPosition({ lineNumber: this._hoverOnLine, column: 1 });
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,15 @@ import { DocumentSymbol, SymbolKind } from 'vs/editor/common/languages';
import { StickyLineCandidate, StickyLineCandidateProvider } from 'vs/editor/contrib/stickyScroll/browser/stickyScrollProvider';
import { EditorOption } from 'vs/editor/common/config/editorOptions';
import { ILogService, NullLogService } from 'vs/platform/log/common/log';
import { IContextMenuService } from 'vs/platform/contextview/browser/contextView';
import { mock } from 'vs/base/test/common/mock';

suite('Sticky Scroll Tests', () => {

const serviceCollection = new ServiceCollection(
[ILanguageFeaturesService, new LanguageFeaturesService()],
[ILogService, new NullLogService()]
[ILogService, new NullLogService()],
[IContextMenuService, new class extends mock<IContextMenuService>() { }]
);

const text = [
Expand Down
1 change: 1 addition & 0 deletions src/vs/platform/actions/common/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ export class MenuId {
static readonly SearchContext = new MenuId('SearchContext');
static readonly StatusBarWindowIndicatorMenu = new MenuId('StatusBarWindowIndicatorMenu');
static readonly StatusBarRemoteIndicatorMenu = new MenuId('StatusBarRemoteIndicatorMenu');
static readonly StickyScrollContext = new MenuId('StickyScrollContext');
static readonly TestItem = new MenuId('TestItem');
static readonly TestItemGutter = new MenuId('TestItemGutter');
static readonly TestPeekElement = new MenuId('TestPeekElement');
Expand Down
3 changes: 2 additions & 1 deletion src/vs/workbench/browser/parts/editor/breadcrumbsControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -512,7 +512,8 @@ registerAction2(class ToggleBreadcrumb extends Action2 {
menu: [
{ id: MenuId.CommandPalette },
{ id: MenuId.MenubarViewMenu, group: '5_editor', order: 3 },
{ id: MenuId.NotebookToolbar, group: 'notebookLayout', order: 2 }
{ id: MenuId.NotebookToolbar, group: 'notebookLayout', order: 2 },
{ id: MenuId.StickyScrollContext }
]
});
}
Expand Down