1
1
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:
kahole 2019-12-12 12:35:55 +01:00
parent b94d2ecea1
commit 50430b3d8e
7 changed files with 23 additions and 29 deletions

View File

@ -1,4 +1,3 @@
# TODO
## General
- Use existing tooling as much as possible

View File

@ -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];

View File

@ -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;
// }
}

View File

@ -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 {

View File

@ -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];
}
}

View File

@ -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;
}

View File

@ -14,4 +14,6 @@ export class SectionHeaderView extends TextView {
super();
this.textContent = `${_section.valueOf()}${count ? " (" + count + ")" : ""}`;
}
onClicked() { return undefined; }
}