mirror of
https://github.com/kahole/edamagit.git
synced 2024-09-11 07:15:31 +03:00
fix clicking and highlighting of sections
This commit is contained in:
parent
b94d2ecea1
commit
50430b3d8e
@ -18,8 +18,13 @@ export function magitStatus() {
|
||||
|
||||
// TODO: clean up this mess
|
||||
|
||||
// [, repository] = Object.entries(magitRepositories).filter(
|
||||
// ([key, repo]) => FilePathUtils.isDescendant(key, rootPath))[0];
|
||||
let repos = Object.entries(magitRepositories).filter(
|
||||
([key, repo]) => FilePathUtils.isDescendant(key, rootPath));
|
||||
|
||||
if (repos.length > 0) {
|
||||
console.log("reuse repo");
|
||||
[, repository] = repos[0];
|
||||
}
|
||||
|
||||
if (!repository) {
|
||||
repository = gitApi.repositories.filter(r => FilePathUtils.isDescendant(r.rootUri.fsPath, rootPath))[0];
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { window, TextEditor, Range, workspace } from "vscode";
|
||||
import * as Constants from '../common/constants';
|
||||
import { magitRepositories } from "../extension";
|
||||
import { HunkView } from "../views/changes/HunkView";
|
||||
|
||||
export function magitVisitAtPoint() {
|
||||
|
||||
@ -16,28 +17,19 @@ export function magitVisitAtPoint() {
|
||||
let currentView = currentRepository.views!.get(editor.document.uri.toString());
|
||||
|
||||
if (currentView) {
|
||||
let result = currentView.click(editor.selection.active);
|
||||
let clickedView = currentView.click(editor.selection.active);
|
||||
console.log(editor.selection.active.line);
|
||||
console.log(result);
|
||||
console.log(clickedView);
|
||||
|
||||
// TODO: Is this a good way of solving this?
|
||||
if (clickedView instanceof HunkView) {
|
||||
// (clickedView as HunkView).changeHunk.diff
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
// let selectedLine = editor.document.getText().split(Constants.LineSplitterRegex)[editor.selection.active.line];
|
||||
// console.log(selectedLine);
|
||||
}
|
||||
}
|
||||
|
||||
// function getRequestText(editor: TextEditor): string | null {
|
||||
// if (!editor || !editor.document) {
|
||||
// return null;
|
||||
// }
|
||||
|
||||
// let selectedText: string | null;
|
||||
// if (editor.selection.isEmpty || range) {
|
||||
// const activeLine = !range ? editor.selection.active.line : range.start.line;
|
||||
// selectedText = Selector.getDelimitedText(editor.document.getText(), activeLine);
|
||||
// } else {
|
||||
// selectedText = editor.document.getText(editor.selection);
|
||||
// }
|
||||
|
||||
// return selectedText;
|
||||
// }
|
||||
}
|
@ -9,6 +9,8 @@ export class ChangeHeaderView extends TextView {
|
||||
let statusLabel = mapFileStatusToLabel(this.change.status);
|
||||
this.textContent = `${statusLabel ? statusLabel + " " : ""}${this.change.uri.path}`;
|
||||
}
|
||||
|
||||
onClicked() { return undefined; }
|
||||
}
|
||||
|
||||
function mapFileStatusToLabel(status: Status): string {
|
||||
|
@ -15,10 +15,4 @@ export class ChangeSectionView extends View {
|
||||
new LineBreakView()
|
||||
];
|
||||
}
|
||||
|
||||
onClicked() {
|
||||
// If clicked on section, call section header onClick
|
||||
// subView clicks are prioritized
|
||||
return this.subViews[0];
|
||||
}
|
||||
}
|
@ -4,7 +4,7 @@ import { TextView } from "../abstract/textView";
|
||||
export class HunkView extends TextView {
|
||||
isFoldable = true;
|
||||
|
||||
constructor(private changeHunk: MagitChangeHunk) {
|
||||
constructor(public changeHunk: MagitChangeHunk) {
|
||||
super();
|
||||
this.textContent = changeHunk.diff;
|
||||
}
|
||||
|
@ -14,4 +14,6 @@ export class SectionHeaderView extends TextView {
|
||||
super();
|
||||
this.textContent = `${_section.valueOf()}${count ? " (" + count + ")" : ""}`;
|
||||
}
|
||||
|
||||
onClicked() { return undefined; }
|
||||
}
|
Loading…
Reference in New Issue
Block a user