Skip to content

Commit

Permalink
fix: macro command editor and url line number sync (#2295)
Browse files Browse the repository at this point in the history
  • Loading branch information
ert78gb authored Jun 1, 2024
1 parent 0a11469 commit 31feb46
Showing 1 changed file with 9 additions and 1 deletion.
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

0 comments on commit 31feb46

Please sign in to comment.