Skip to content

Minor tweaks to long distance hint#278457

Merged
benibenj merged 1 commit intomainfrom
benibenj/frequent-dolphin
Nov 19, 2025
Merged

Minor tweaks to long distance hint#278457
benibenj merged 1 commit intomainfrom
benibenj/frequent-dolphin

Conversation

@benibenj
Copy link
Contributor

Copilot Generated Description: Adjust imports and refine the implementation of the long distance hint feature, including updates to widget content handling and style properties.

Copilot AI review requested due to automatic review settings November 19, 2025 22:28
@benibenj benibenj enabled auto-merge November 19, 2025 22:28
@benibenj benibenj self-assigned this Nov 19, 2025
@vs-code-engineering vs-code-engineering bot added this to the November 2025 milestone Nov 19, 2025
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the long distance hint widget implementation to use a derived observable pattern and enhances the UI with improved layout and visual indicators.

  • Wraps _widgetContent in a derived observable to better integrate with the reactive architecture
  • Adds a "Go To Edit" label with directional arrow icon to indicate edit location relative to the hint
  • Improves code organization by extracting outline rendering logic into a separate helper function isEditBelowHint

function isEditBelowHint(viewState: ILongDistanceViewState): boolean {
const hintLineNumber = viewState.hint.lineNumber;
const editStartLineNumber = viewState.diff[0]?.original.startLineNumber;
return hintLineNumber < editStartLineNumber;
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The function doesn't handle the case where viewState.diff is an empty array. If viewState.diff[0] is undefined, editStartLineNumber will be undefined, causing the comparison hintLineNumber < editStartLineNumber to return false (comparing number with undefined). Consider adding a fallback or explicit check:

function isEditBelowHint(viewState: ILongDistanceViewState): boolean {
	const hintLineNumber = viewState.hint.lineNumber;
	const editStartLineNumber = viewState.diff[0]?.original.startLineNumber;
	return editStartLineNumber !== undefined && hintLineNumber < editStartLineNumber;
}
Suggested change
return hintLineNumber < editStartLineNumber;
return editStartLineNumber !== undefined && hintLineNumber < editStartLineNumber;

Copilot uses AI. Check for mistakes.
this._viewState.get()?.model.jump();
}
}, [
private readonly _widgetContent = derived(this, reader => // TODO how to not use derived but not move into constructor?
Copy link

Copilot AI Nov 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[nitpick] Consider resolving the TODO comment before merging. The comment asks "how to not use derived but not move into constructor?" This suggests uncertainty about the current approach. If this is the intended final implementation, the TODO should be removed or converted to a regular comment explaining why derived is necessary here.

Suggested change
private readonly _widgetContent = derived(this, reader => // TODO how to not use derived but not move into constructor?
// The use of `derived` here is necessary to ensure `_widgetContent` reacts to changes in its dependencies.
private readonly _widgetContent = derived(this, reader =>

Copilot uses AI. Check for mistakes.
const icon = SymbolKinds.toIcon(item.kind);
outlineElements.push(n.div({
class: 'breadcrumb-item',
style: { display: 'flex', alignItems: 'center', flex: '1 1 auto', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be a class somewhere?

const arrowIcon = isEditBelowHint(viewState) ? Codicon.arrowDown : Codicon.arrowUp;
children.push(n.div({
class: 'go-to-label',
style: { display: 'flex', alignItems: 'center', flex: '0 0 auto', marginLeft: '14px' },
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

@benibenj benibenj merged commit 5408636 into main Nov 19, 2025
33 of 34 checks passed
@benibenj benibenj deleted the benibenj/frequent-dolphin branch November 19, 2025 23:39
@vs-code-engineering vs-code-engineering bot locked and limited conversation to collaborators Jan 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants