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

Remove extraneous 'Find and Replace...' item from the edit menu and codemirror #6350

Merged
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 0 additions & 24 deletions packages/codemirror-extension/src/index.ts
Expand Up @@ -42,8 +42,6 @@ namespace CommandIDs {

export const find = 'codemirror:find';

export const findAndReplace = 'codemirror:find-and-replace';

export const goToLine = 'codemirror:go-to-line';
}

Expand Down Expand Up @@ -284,19 +282,6 @@ function activateEditorCommands(
isEnabled
});

commands.addCommand(CommandIDs.findAndReplace, {
label: 'Find and Replace...',
execute: () => {
let widget = tracker.currentWidget;
if (!widget) {
return;
}
let editor = widget.content.editor as CodeMirrorEditor;
editor.execCommand('replace');
},
isEnabled
});

commands.addCommand(CommandIDs.goToLine, {
label: 'Go to Line...',
execute: () => {
Expand Down Expand Up @@ -395,15 +380,6 @@ function activateEditorCommands(
// Add the syntax highlighting submenu to the `View` menu.
mainMenu.viewMenu.addGroup([{ type: 'submenu', submenu: modeMenu }], 40);

// Add find-replace capabilities to the edit menu.
mainMenu.editMenu.findReplacers.add({
tracker,
findAndReplace: (widget: IDocumentWidget<FileEditor>) => {
let editor = widget.content.editor as CodeMirrorEditor;
editor.execCommand('replace');
}
} as IEditMenu.IFindReplacer<IDocumentWidget<FileEditor>>);

// Add go to line capabilities to the edit menu.
mainMenu.editMenu.goToLiners.add({
tracker,
Expand Down
16 changes: 0 additions & 16 deletions packages/mainmenu-extension/src/index.ts
Expand Up @@ -51,8 +51,6 @@ export namespace CommandIDs {

export const find = 'editmenu:find';

export const findAndReplace = 'editmenu:find-and-replace';

export const goToLine = 'editmenu:go-to-line';

export const openFile = 'filemenu:open';
Expand Down Expand Up @@ -280,20 +278,6 @@ export function createEditMenu(app: JupyterFrontEnd, menu: EditMenu): void {
10
);

// Add the find-replace command to the Edit menu.
commands.addCommand(CommandIDs.findAndReplace, {
label: 'Find and Replace…',
isEnabled: Private.delegateEnabled(
app,
menu.findReplacers,
'findAndReplace'
),
execute: Private.delegateExecute(app, menu.findReplacers, 'findAndReplace')
});
menu.addGroup(
[{ command: CommandIDs.find }, { command: CommandIDs.findAndReplace }],
200
);
commands.addCommand(CommandIDs.goToLine, {
label: 'Go to Line…',
isEnabled: Private.delegateEnabled(app, menu.goToLiners, 'goToLine'),
Expand Down
23 changes: 0 additions & 23 deletions packages/mainmenu/src/edit.ts
Expand Up @@ -19,11 +19,6 @@ export interface IEditMenu extends IJupyterLabMenu {
*/
readonly clearers: Set<IEditMenu.IClearer<Widget>>;

/**
* A set storing IFindReplacers for the Edit menu.
*/
readonly findReplacers: Set<IEditMenu.IFindReplacer<Widget>>;

/**
* A set storing IGoToLiners for the Edit menu.
*/
Expand All @@ -45,8 +40,6 @@ export class EditMenu extends JupyterLabMenu implements IEditMenu {

this.clearers = new Set<IEditMenu.IClearer<Widget>>();

this.findReplacers = new Set<IEditMenu.IFindReplacer<Widget>>();

this.goToLiners = new Set<IEditMenu.IGoToLiner<Widget>>();
}

Expand All @@ -60,11 +53,6 @@ export class EditMenu extends JupyterLabMenu implements IEditMenu {
*/
readonly clearers: Set<IEditMenu.IClearer<Widget>>;

/**
* A set storing IFindReplacers for the Edit menu.
*/
readonly findReplacers: Set<IEditMenu.IFindReplacer<Widget>>;

/**
* A set storing IGoToLiners for the Edit menu.
*/
Expand All @@ -76,7 +64,6 @@ export class EditMenu extends JupyterLabMenu implements IEditMenu {
dispose(): void {
this.undoers.clear();
this.clearers.clear();
this.findReplacers.clear();
super.dispose();
}
}
Expand Down Expand Up @@ -125,16 +112,6 @@ export namespace IEditMenu {
clearAll?: (widget: T) => void;
}

/**
* Interface for an activity that uses Find/Find+Replace.
*/
export interface IFindReplacer<T extends Widget> extends IMenuExtender<T> {
/**
* Execute a find/replace command for the activity.
*/
findAndReplace?: (widget: T) => void;
}

/**
* Interface for an activity that uses Go to Line.
*/
Expand Down
15 changes: 0 additions & 15 deletions tests/test-mainmenu/src/edit.spec.ts
Expand Up @@ -90,20 +90,5 @@ describe('@jupyterlab/mainmenu', () => {
expect(wodget.state).to.equal('clearAll');
});
});

describe('#findReplacers', () => {
it('should allow setting of an IFindReplacer', () => {
const finder: IEditMenu.IFindReplacer<Wodget> = {
tracker,
findAndReplace: widget => {
widget.state = 'findAndReplace';
return;
}
};
menu.findReplacers.add(finder);
void delegateExecute(wodget, menu.findReplacers, 'findAndReplace');
expect(wodget.state).to.equal('findAndReplace');
});
});
});
});