0">
{{jumpedToLineIndex + 1}} of {{highlightedRanges.length}}
diff --git a/src/app/shared/components/file-viewer/file-viewer.component.scss b/src/app/shared/components/file-viewer/file-viewer.component.scss
index 06e566d..c3e98fa 100644
--- a/src/app/shared/components/file-viewer/file-viewer.component.scss
+++ b/src/app/shared/components/file-viewer/file-viewer.component.scss
@@ -58,6 +58,11 @@ app-path-text {
margin-bottom: 4px;
}
+.file-viewer-menu {
+ position: absolute;
+ line-height: 0;
+}
+
.jump-lines-icons {
position: absolute;
line-height: 0;
diff --git a/src/app/shared/components/file-viewer/file-viewer.component.ts b/src/app/shared/components/file-viewer/file-viewer.component.ts
index d3dc50f..1d161eb 100644
--- a/src/app/shared/components/file-viewer/file-viewer.component.ts
+++ b/src/app/shared/components/file-viewer/file-viewer.component.ts
@@ -6,6 +6,7 @@ import { AceComponent, AceConfigInterface } from 'ngx-ace-wrapper';
import { Project } from 'src/app/core/services/gitlab-api/models/project';
import { SettingsService } from 'src/app/settings/settings.service';
import { Range } from 'brace';
+import { GitlabWwwService } from 'src/app/core/services/gitlab-api/gitlab-www.service';
import 'brace';
import 'brace/mode/javascript';
@@ -50,6 +51,7 @@ export class FileViewerComponent extends Modal implements On
@ViewChild('ace', { static: true })
ace: AceComponent;
aceConfig: AceConfigInterface;
+ aceInitialized = false;
project: Project;
filename: string;
@@ -62,7 +64,8 @@ export class FileViewerComponent extends Modal implements On
highlightedRanges: Range[] = [];
jumpedToLineIndex = -1;
- constructor(private filesApiService: FilesApiService, private settingsService: SettingsService) {
+ constructor(private filesApiService: FilesApiService, private settingsService: SettingsService,
+ private gitlabWwwService: GitlabWwwService) {
super();
}
@@ -107,6 +110,11 @@ export class FileViewerComponent extends Modal implements On
this.goToHighlight(this.jumpedToLineIndex);
}
+ openGitLabUrl(): string {
+ const {row} = this.provideCursorPosition();
+ return this.gitlabWwwService.openFileUrl(this.project, this.filename, row);
+ }
+
private goToHighlight(index: number): void {
const range = this.highlightedRanges[index];
const ace = this.ace.directiveRef.ace();
@@ -131,6 +139,7 @@ export class FileViewerComponent extends Modal implements On
if (this.highlightedRanges.length > 0) {
this.goToNextHighlight();
}
+ this.aceInitialized = true;
});
}
@@ -142,4 +151,8 @@ export class FileViewerComponent extends Modal implements On
private decodeContent(content: string): string {
return decodeURIComponent(escape(atob(content)));
}
+
+ private provideCursorPosition(): {row?: number; column?: number} {
+ return this.aceInitialized ? this.ace.directiveRef.ace().getCursorPosition() : {};
+ }
}