mirror of
https://github.com/arduino/arduino-ide.git
synced 2025-07-27 05:06:42 +00:00
comment/uncomment line
Signed-off-by: Akos Kitta <kittaakos@typefox.io>
This commit is contained in:
parent
939a905a6b
commit
c0cadf2b9b
@ -98,6 +98,7 @@ import { UploadSketch } from './contributions/upload-sketch';
|
|||||||
import { CommonFrontendContribution } from './customization/core/common-frontend-contribution';
|
import { CommonFrontendContribution } from './customization/core/common-frontend-contribution';
|
||||||
import { CopyToForum } from './contributions/copy-to-forum';
|
import { CopyToForum } from './contributions/copy-to-forum';
|
||||||
import { GoToLine } from './contributions/go-to-line';
|
import { GoToLine } from './contributions/go-to-line';
|
||||||
|
import { ToggleComment } from './contributions/toggle-comment';
|
||||||
|
|
||||||
const ElementQueries = require('css-element-queries/src/ElementQueries');
|
const ElementQueries = require('css-element-queries/src/ElementQueries');
|
||||||
|
|
||||||
@ -328,4 +329,5 @@ export default new ContainerModule((bind: interfaces.Bind, unbind: interfaces.Un
|
|||||||
Contribution.configure(bind, UploadSketch);
|
Contribution.configure(bind, UploadSketch);
|
||||||
Contribution.configure(bind, CopyToForum);
|
Contribution.configure(bind, CopyToForum);
|
||||||
Contribution.configure(bind, GoToLine);
|
Contribution.configure(bind, GoToLine);
|
||||||
|
Contribution.configure(bind, ToggleComment);
|
||||||
});
|
});
|
||||||
|
@ -87,6 +87,16 @@ export abstract class EditorContribution extends Contribution {
|
|||||||
return editor instanceof MonacoEditor ? editor : undefined;
|
return editor instanceof MonacoEditor ? editor : undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected async run(commandId: string): Promise<any> {
|
||||||
|
const editor = await this.current();
|
||||||
|
if (editor) {
|
||||||
|
const action = editor.getControl().getAction(commandId);
|
||||||
|
if (action) {
|
||||||
|
return action.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export namespace Contribution {
|
export namespace Contribution {
|
||||||
|
@ -27,11 +27,7 @@ export class GoToLine extends EditorContribution {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async goToLine(): Promise<void> {
|
async goToLine(): Promise<void> {
|
||||||
const editor = await this.current();
|
return this.run('editor.action.gotoLine');
|
||||||
if (editor) {
|
|
||||||
const action = editor.getControl().getAction('editor.action.gotoLine');
|
|
||||||
return action.run();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,41 @@
|
|||||||
|
import { injectable } from 'inversify';
|
||||||
|
import { EditorContribution, Command, MenuModelRegistry, KeybindingRegistry, CommandRegistry } from './contribution';
|
||||||
|
import { ArduinoMenus } from '../menu/arduino-menus';
|
||||||
|
|
||||||
|
@injectable()
|
||||||
|
export class ToggleComment extends EditorContribution {
|
||||||
|
|
||||||
|
registerCommands(registry: CommandRegistry): void {
|
||||||
|
registry.registerCommand(ToggleComment.Commands.TOGGLE_COMMENT, {
|
||||||
|
execute: () => this.toggleComment()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
registerMenus(registry: MenuModelRegistry): void {
|
||||||
|
registry.registerMenuAction(ArduinoMenus.EDIT__CODE_CONTROL_GROUP, {
|
||||||
|
commandId: ToggleComment.Commands.TOGGLE_COMMENT.id,
|
||||||
|
label: 'Comment/Uncomment',
|
||||||
|
order: '0'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
registerKeybindings(registry: KeybindingRegistry): void {
|
||||||
|
registry.registerKeybinding({
|
||||||
|
command: ToggleComment.Commands.TOGGLE_COMMENT.id,
|
||||||
|
keybinding: 'CtrlCmd+L'
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
async toggleComment(): Promise<void> {
|
||||||
|
return this.run('editor.action.commentLine');
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
export namespace ToggleComment {
|
||||||
|
export namespace Commands {
|
||||||
|
export const TOGGLE_COMMENT: Command = {
|
||||||
|
id: 'arduino-toggle-comment'
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user