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

fix: macro command editor and url line number sync #2295

Merged
merged 1 commit into from
Jun 1, 2024
Merged
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 @@ -87,6 +87,7 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA
editor: MonacoStandaloneCodeEditor;
containerHeight = '54px';

private actionIndexQueryParam: string | undefined;
private columnNr = 1;
private lineHeight = 18;
private lineNr = 1;
Expand Down Expand Up @@ -143,6 +144,7 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA
);
// read column and line numbers directly for performance reason.
this.subscriptions.add(this.route.queryParams.subscribe(params => {
this.actionIndexQueryParam = params.actionIndex;
const columnNr = +params.columnNr;
if (!Number.isNaN(columnNr)) {
this.columnNr = columnNr;
Expand Down Expand Up @@ -247,6 +249,11 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA
debounceTime(MACRO_CHANGE_DEBOUNCE_TIME),
distinctUntilChanged(isEqual)
).subscribe(data => {
// there is a debounce so maybe the editor will list the focus
if (!this.isFocused) {
return;
}

this.router.navigate([], {
queryParams: {
columnNr: data.columnNr,
Expand Down Expand Up @@ -446,7 +453,8 @@ export class MacroCommandEditorComponent implements AfterViewInit, ControlValueA
});
}

if (!this.isFocused) {
// use coercing because the query parameter is string
if (!this.isFocused && this.actionIndexQueryParam && this.actionIndexQueryParam == this.index) {
this.editor.focus();
}
});
Expand Down