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

Add Dirty Diff Peek View #13104

Merged
merged 14 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Revise some of the dirty diff related types
  • Loading branch information
pisv committed Apr 16, 2024
commit 1d6ce07cc5acea68e0d9ebd057d89593aef7fb32
12 changes: 9 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,15 @@

- [Previous Changelogs](https://github.com/eclipse-theia/theia/tree/master/doc/changelogs/)

<!-- ## not yet released
## not yet released

<a name="breaking_changes_not_yet_released">[Breaking Changes:](#breaking_changes_not_yet_released)</a> -->
- [scm] added support for dirty diff peek view [#13104](https://github.com/eclipse-theia/theia/pull/13104)

<a name="breaking_changes_not_yet_released">[Breaking Changes:](#breaking_changes_not_yet_released)</a>
- [scm] revised some of the dirty diff related types [#13104](https://github.com/eclipse-theia/theia/pull/13104)
- replaced `DirtyDiff.added/removed/modified` with `changes`, which provides more detailed information about the changes
- changed the semantics of `LineRange` to represent a range that spans up to but not including the `end` line (previously, it included the `end` line)
- changed the signature of `DirtyDiffDecorator.toDeltaDecoration(LineRange | number, EditorDecorationOptions)` to `toDeltaDecoration(Change)`

## v1.48.0 - 03/28/2024

Expand Down Expand Up @@ -95,7 +101,7 @@
- Moved `ThemaIcon` and `ThemeColor` to the common folder
- Minor typing adjustments in QuickPickService: in parti
- FileUploadService: moved id field from data transfer item to the corresponding file info
- The way we instantiate monaco services has changed completely: if you touch monaco services in your code, please read the description in the
- The way we instantiate monaco services has changed completely: if you touch monaco services in your code, please read the description in the
file comment in `monaco-init.ts`.

## v1.46.0 - 01/25/2024
Expand Down
5 changes: 2 additions & 3 deletions packages/git/src/browser/dirty-diff/dirty-diff-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ export class DirtyDiffModel implements Disposable {
update(): void {
const editor = this.editor;
if (!this.shouldRender()) {
this.onDirtyDiffUpdateEmitter.fire({ editor, added: [], removed: [], modified: [] });
this.onDirtyDiffUpdateEmitter.fire({ editor, changes: [] });
return;
}
if (this.updateTimeout) {
Expand Down Expand Up @@ -286,8 +286,7 @@ export namespace DirtyDiffModel {
*/
export function computeDirtyDiff(previous: ContentLines, current: ContentLines): DirtyDiff | undefined {
try {
return diffComputer.computeDirtyDiff(ContentLines.arrayLike(previous), ContentLines.arrayLike(current),
{ rangeMappings: true });
return diffComputer.computeDirtyDiff(ContentLines.arrayLike(previous), ContentLines.arrayLike(current));
} catch {
return undefined;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { TreeWidgetSelection } from '@theia/core/lib/browser/tree/tree-widget-se
import { ScmRepository } from '@theia/scm/lib/browser/scm-repository';
import { ScmService } from '@theia/scm/lib/browser/scm-service';
import { DirtyDiffWidget } from '@theia/scm/lib/browser/dirty-diff/dirty-diff-widget';
import { RangeMapping, LineRange, NormalizedEmptyLineRange } from '@theia/scm/lib/browser/dirty-diff/diff-computer';
import { Change, LineRange } from '@theia/scm/lib/browser/dirty-diff/diff-computer';
import { IChange } from '@theia/monaco-editor-core/esm/vs/editor/common/diff/legacyLinesDiffComputer';
import { TimelineItem } from '@theia/timeline/lib/common/timeline-model';
import { ScmCommandArg, TimelineCommandArg, TreeViewItemReference } from '../../../common';
Expand Down Expand Up @@ -236,15 +236,15 @@ export class PluginMenuCommandAdapter implements MenuCommandAdapter {
protected toScmChangeArgs(...args: any[]): any[] {
const arg = args[0];
if (arg instanceof DirtyDiffWidget) {
const toIChange = (change: RangeMapping): IChange => {
const convert = (range: LineRange | NormalizedEmptyLineRange): [number, number] => {
const toIChange = (change: Change): IChange => {
const convert = (range: LineRange): [number, number] => {
let startLineNumber;
let endLineNumber;
if (!LineRange.isEmpty(range)) {
startLineNumber = range.start + 1;
endLineNumber = range.end + 1;
endLineNumber = range.end;
} else {
startLineNumber = range.start === 0 ? 0 : range.end + 1;
startLineNumber = range.start;
endLineNumber = 0;
}
return [startLineNumber, endLineNumber];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,7 @@ export class ScmDecorationsService {
const previousContent = await previousResource.readContents();
const previousLines = ContentLines.fromString(previousContent);
const currentLines = ContentLines.fromTextEditorDocument(editor.document);
const dirtyDiff = this.diffComputer.computeDirtyDiff(ContentLines.arrayLike(previousLines), ContentLines.arrayLike(currentLines),
{ rangeMappings: true });
const dirtyDiff = this.diffComputer.computeDirtyDiff(ContentLines.arrayLike(previousLines), ContentLines.arrayLike(currentLines));
const update = <DirtyDiffUpdate>{ editor, previousRevisionUri: uri, ...dirtyDiff };
this.decorator.applyDecorations(update);
this.onDirtyDiffUpdateEmitter.fire(update);
Expand Down
Loading