You can hit it by using Compare with
action and --diff
. This is really sad. The editor on the left should only be read-only if the input behind it is really read-only (coming from the git index, for example).
cc @alexandrudima @bpasero
Yes I always wanted that actually :)
On my side it would be pretty easy to just comment out the forcing of readOnly=true
on the left-hand-side. But I need to add an option to allow the workbench to make the git diff case left-hand-side readOnly.
There's also the inline diff case, where I cannot make the "original" editable.
@alexandrudima yeah I think we know in all places if the left hand side should be editable or not, I think it would only be the file-2-file compare where this applies.
Ok, there is a new option originalEditable
to the diff editor. It is false by default.
@alexandrudima cool, let me pick this up then...
@alexandrudima so by default this option is true or false?
:) Wrote in comment and in jsdoc: it is false by default.
:+1:
Hm, I forgot that this adds a bit more complexity to how actions operate on the active editor and how dirty state is indicated. I think I was a bit too optimistic for March but will check. Otherwise April it will be.
Surprisingly lots of things actually do work in terms of dirty indication but the one for the actual editor does not because it only checks for the right hand side.
If this something that can be done as a first PR? Would be great if you could indicate issues that would be easy wins for an outsider to contribute. I really really really really want git diffing to work on the right side. I will buy you a coffee/beer if you fix this :stuck_out_tongue_winking_eye:
@nojvek you can always edit on the right hand side when comparing outgoing changes in git!
(this feature request is about being able to edit either the left hand or the right hand side when comparing 2 files)
Oh I just saw that after doing an upgrade. This seems fairly recent. This really bought me a lot of joy when it worked.
It was always possible to edit the right hand side of the diff editor for git changes view.
From @alexandrudima
- in the explorer,
- right click on a file A, choose "Select for compare"
- right click on another file, choose "Compare with A"
- observe: left hand side of the diff is not editable
Fix: use
originalEditable
when the diff editor models are both editable files.
It would be cool to have two buttons in the middle "copy changes from left to right" and vice versa.
Like this (Eclipse):
Yeah the copy changes is super useful.
So the option works
"diffEditor.originalEditable": true
but VSCode 1.20.0 (1.20.0) complains about "Unknown configuration setting":
What's also strange (mac here): Cmd+S
does not save the original! The UX handling is really weird with the original file and I had lost my editing once. I have to close the diff window after editing and save the unsaved original which is not how I assumed the saving should work with this option turned on.
It would be nice if there was read-only on/off control of both sides of the diff editor. In GitLens, when diffing history both sides should be read-only.
Can someone explain to me where I can set originalEditable ?
Really confused. That option is not listed on my settings v1.27.1
@duartemolha, open VSCode, open the command palette (on windows it's Ctrl + shift+ P), then type setting and open the Preferences: Open Settings (JSON)
.
Then you will see someting like this: https://code.visualstudio.com/assets/docs/getstarted/settings/hero.png
Then paste "diffEditor.originalEditable": true,
inside the {}
on the rigth part (in the image above, that would be just below editor.minimap....
Don't forget to end you line with a ,
!
This setting is just working for the split view. If switched to inline view, i can't even just select (nor copy) the original text.
would be nice to have that available also in the "ui" version of "settings"
Having both editable is very convenient for refactoring:
Nice. So Thanks :-)
To further enhance this feature, it would be nice if an edited source (left side) could consequently being saved in the "diff-view", that already works for the target-side (right).
It would be cool to have two buttons in the middle "copy changes from left to right" and vice versa.
Like this (Eclipse):
The ability to move code from the original to the new is pretty fundamental in vcs compare tools. I don't think I've ever found a diff tool before that doesn't have it.
"diffEditor.originalEditable": true,
works perfectly! Is there any way to make this the new default? I can't imagine ever not wanting this on.
I pushed a change to enable this by default if the left-hand editor is not readonly. Pressing CtrlCmd+S
or File > Save
will now save both sides of the diff editor.
Feedback welcome, it will be in tomorrows insider build: https://code.visualstudio.com/insiders/
@bpasero Thanks for implementing! Now that this is closed, is it possible to finally implement https://github.com/microsoft/vscode/issues/25887 and https://github.com/microsoft/vscode/issues/37350? This would address a critically missing piece of editor functionality that has been heavily requested for over two years.
Also mentioning @alexandrudima who has been consolidating a number of issues to #25887
Thanks much!
Most helpful comment
So the option works
but VSCode 1.20.0 (1.20.0) complains about "Unknown configuration setting":