-
Notifications
You must be signed in to change notification settings - Fork 33.3k
Added new config to keep the same line when switching between diffEditors #155395
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
base: main
Are you sure you want to change the base?
Added new config to keep the same line when switching between diffEditors #155395
Conversation
Also, I don't think we need a config for this. I don't see a reason why you would not want the cursors to be synchronized. |
The current implementation jumps to the last focused line, I see it potentially useful for merge conflicts. Maybe we can keep the config but instead of a boolean we can explicit the "strategy" that would be either |
a062f57
to
0e054c6
Compare
|
||
const configurationService = accessor.get(IConfigurationService); | ||
const keepLine = configurationService.getValue<boolean>('diffEditor.keepLine'); | ||
|
||
if (keepLine && source) { | ||
const position = source.getPosition(); | ||
|
||
if (position) { | ||
const equivalentLineNumber = mode === FocusTextDiffEditorMode.Original ? | ||
control.getDiffLineInformationForModified(position.lineNumber)?.equivalentLineNumber : | ||
control.getDiffLineInformationForOriginal(position.lineNumber)?.equivalentLineNumber; | ||
|
||
if (equivalentLineNumber !== undefined) { | ||
destination.setPosition(new Position(equivalentLineNumber, position.column)); | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you make this code nicer? It is very deeply nested. Maybe a function with early returns makes sense here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh wow, you're absolutely right, that nesting is terrible!
I updated the branch now, thanks for pointing it out!
@hediet @Balastrong Hello! I stumbled upon this PR when trying to figure out if it's possible to sync the cursor between diff panels today. Is this PR still expected to be merged? Is there any help needed? It would be shame to leave it like this, unless there's already a different way to do it. |
I made an extension kinda same to this. |
This PR fixes #155036.
Added a new boolean config
diffEditor.keepLine
.If enabled, switching between diffEditors with a command (
workbench.action.compareEditor.focusPrimarySide
,workbench.action.compareEditor.focusSecondarySide
,workbench.action.compareEditor.focusOtherSide
) will keep the cursor on the same line.