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

Support word wrap in the diff editor #11387

Closed
bpasero opened this issue Sep 1, 2016 · 72 comments · Fixed by #110268
Closed

Support word wrap in the diff editor #11387

bpasero opened this issue Sep 1, 2016 · 72 comments · Fixed by #110268
Assignees
Labels
diff-editor Diff editor mode issues editor-wrapping Editor line wrapping issues feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan
Milestone

Comments

@bpasero
Copy link
Member

bpasero commented Sep 1, 2016

I cannot get word wrapping enabled in a diff editor when using that action but maybe there is no word wrapping for diff editors?

@bpasero bpasero added the editor label Sep 1, 2016
@alexdima alexdima added feature-request Request for new features or functionality diff-editor Diff editor mode issues labels Sep 1, 2016
@alexdima alexdima added this to the Backlog milestone Sep 1, 2016
@alexdima alexdima removed their assignment Sep 1, 2016
@alexdima
Copy link
Member

alexdima commented Sep 1, 2016

Yes, word wrapping was never supported in diff editor -- has to do with aligning lines that wrap.

@bpasero
Copy link
Member Author

bpasero commented Sep 1, 2016

Got it 👍

@vogler
Copy link

vogler commented Oct 6, 2016

It would be nice if the diff editor also respected the word wrap setting.

Another related issue:
Both panes scroll in sync - but only to their content's width instead of the maximum of both panes.
So if I scroll on the left and come to a change where the right version is longer, I have to move the mouse to the right pane in order to be able to scroll to the end of the line.

@Fania
Copy link

Fania commented Nov 7, 2016

I work on Latex projects with long paragraphs of text. Find and replace is almost unusable without word wrap. I can see how it wouldn't bother me much on my python projects maybe, but in Latex it's terrible.

@jakearchibald
Copy link

I'm a huge fan of vscode, but this is a blocker for me when it comes to using it for diffing.

@matt-cooper
Copy link

matt-cooper commented Jun 12, 2017

Is there some way to configure VS Code so that it launches an external Diff Tool instead (e.g. Araxis Merge) as a temporary workaround until this issue is fixed? (Even if I have to manually click a button to launch the the 3rd party diff tool.)

-edit-
I found a solution by adding this to my ~/.gitconfig file:

[mergetool "araxis"]
	path = /Applications/Araxis Merge.app/Contents/Utilities/compare
[diff]
    tool = araxis
[merge]
    tool = araxis

and then installed the "GitDiffer" VSCode extension and now when I right click a file in the Source Control tab of my VSCode window, the "Launch difftool for ..." context menu item will then launch Araxis Merge. Multiple selection doesn't work though (cannot select all changed files and load all of their diffs) but this is a good enough workaround for now.

@Dominik-K
Copy link

Dominik-K commented Jul 14, 2017

@alexandrudima If aligning lines is the blocker for this request, then the "flowing lines" diff view

image

mentioned in #25887 would solve this, right?

@protoEvangelion
Copy link

Are there any updates related to this issue?

@yaronyg
Copy link
Member

yaronyg commented Nov 5, 2017

I'm trying to diff MD files and the lack of word wrap support makes it pretty much impossible. :(

@kappanneo
Copy link

Same problem here, can't work on Latex diffs.

@pavelkouril
Copy link

Yes, this is a huge issue, makes it unuseable for a lot of diffing. :(

@pumpkinlink
Copy link

pumpkinlink commented Dec 7, 2017

A good solution about aligning would be to break the line at any character, as opposed to breaking only between words, actually that is how I have my Vim setup, it is good for small screens. Example:

This (breaking always at exactly 80-char):

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque suscipit r
isus quis pulvinar elementum. Aliquam faucibus nibh in turpis semper mollis. Nul
la euismod diam eu feugiat venenatis. Nullam quis ex vel mi condimentum maximus 
id id massa. Donec felis sem, porttitor at ligula eu, dapibus ultrices ante. Ali
quam quis accumsan arcu. Donec sollicitudin a ante id scelerisque. Aliquam eget 
lectus lectus. Quisque mattis, lectus non auctor auctor, nisi dui accumsan est, 
nec finibus ligula est nec est. Praesent scelerisque in sapien et consequat. Mae
cenas sollicitudin magna augue, quis ultrices urna pulvinar ut. Proin nisi turpi
s, fringilla eget diam eu, gravida iaculis tellus. Etiam et gravida nulla. Ut no
n faucibus lacus. Nulla facilisi.

Instead of this (breaking on last word separator before 80-char):

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque suscipit 
risus quis pulvinar elementum. Aliquam faucibus nibh in turpis semper mollis. 
Nulla euismod diam eu feugiat venenatis. Nullam quis ex vel mi condimentum 
maximus id id massa. Donec felis sem, porttitor at ligula eu, dapibus ultrices 
ante. Aliquam quis accumsan arcu. Donec sollicitudin a ante id scelerisque. 
Aliquam eget lectus lectus. Quisque mattis, lectus non auctor auctor, nisi dui 
accumsan est, nec finibus ligula est nec est. Praesent scelerisque in sapien et 
consequat. Maecenas sollicitudin magna augue, quis ultrices urna pulvinar ut. 
Proin nisi turpis, fringilla eget diam eu, gravida iaculis tellus. Etiam et 
gravida nulla. Ut non faucibus lacus. Nulla facilisi.

@jakearchibald
Copy link

@pumpkinlink I wouldn't mind that as an option, but don't think it should be the default.

I like what Github's split view does https://github.com/w3c/ServiceWorker/pull/1229/files?diff=split.

@nikkifurls
Copy link

I would also like to know if there are any updates on this issue. Comparing files is very difficult at the moment due to the lack of word wrap in the Git diff view. Has anyone found any workarounds?

@michou
Copy link

michou commented Sep 5, 2018

@alexandrudima re:

Yes, word wrapping was never supported in diff editor -- has to do with aligning lines that wrap.

The thing is, it doesn't work with inline diffs, either. Don't know if that would be easier to implement, but I'd take this half-solution any time.

<backstory> I was SO thrilled to be able to review code inside VSCode only to stumble on a markdown file with lines long enough to send me back to the browser screaming 😱</backstory>

@bpasero bpasero changed the title "Toggle Word Wrap" does nothing for diff editor Support word wrap in the diff editor Sep 14, 2018
@FMuro
Copy link

FMuro commented Sep 4, 2020

I made a feature request for a word based diff on vscode, could it be an alternative to what people are asking in this post?

#103285

I don't see the relation.

@Nadano
Copy link

Nadano commented Sep 4, 2020

At least until word wrapping it done it should be possible to work with long lines if you can see the changes inline

@PeteX
Copy link

PeteX commented Sep 4, 2020

Word diff would be somewhat useful to me, but it's not as important as line wrapping. You get something approximating word diff anyway, because VSCode highlights the changed characters as well as the changed lines.

(The funny thing is that VSCode highlights changed characters but doesn't wrap lines. Atom wraps lines but doesn't highlight changed characters. When comparing documentation files with long lines, you just can't win!)

@frodal
Copy link

frodal commented Sep 4, 2020

Instead of using an external diff tool with VSCode, the Rewrap extension can be used to break lines while looking at the diff with VSCode. The extension can be used to break lines at the cursor location by pressing Alt+Q. Rewrap also supports automatic wrapping (off by default) https://github.com/stkb/Rewrap/wiki/Auto-wrap. Rewrap requires no further settings to use. This behavior should be implemented in the diff editor of VSCode.

See also https://stackoverflow.com/questions/43122175/automatically-hard-wrap-lines-at-column-in-vscode/45883430

@SergeyMatsiupa
Copy link

Instead of using an external diff tool with VSCode, the Rewrap extension can be used to break lines while looking at the diff with VSCode.

@frodal sorry but looks like it doesn't work properly (for two in-memory documents at least):
Screenshot_2020-09-05_17-55-01

@frodal
Copy link

frodal commented Sep 12, 2020

@SergeyMatsiupa have you tried changing the settings of Rewrap, e.g., the wrapping column setting?
Here's an example with Latex, I guess it's not perfect.
image

image

@technic
Copy link

technic commented Sep 12, 2020

@frodal

This looks nice. Could you provide instructions how to get the wrapping work like on your second screenshot?

@frodal
Copy link

frodal commented Sep 14, 2020

@technic see my previous post: #11387 (comment)

@floschl
Copy link

floschl commented Sep 14, 2020

I think the initial intention of this feature request is rather to display the differences of a long line auto-wrapped in a multi-line, without making changes in the code, i.e. inserting new lines. The Rewrap extension seems to insert new lines!?

@pmattei
Copy link

pmattei commented Sep 14, 2020

I totally approve @floschl objection.
@frodal Thank for your workaround, but it cannot be used in many work situations.
For my example, we work on differents IDE (VScode/emacs/vim)
We already had a debate about the max line code length, with no concensus.
Just one rule, "please, do not commit to only modify code appearance, respect other coworkers work."
So it happend, that I have to review some lines with more than 300 characters.
With your workaround, I should rewrap all modified files before each review, and if I want to propose a diff, I should revert my modifications before. Not really efficient.
Other coworkers do not have this problem on emacs for example.

@gl4eqen
Copy link

gl4eqen commented Oct 3, 2020

I'm impressed that this issue just hangs in here for 4 years now.

@bknaepen
Copy link

I also would like this feature added...

@piersdeseilligny
Copy link

This issue also makes it impossible to diff fountain documents. Although this issue applies to any type of markup really, which means it isn't exactly an edge case or anything.

Why is something like this on the backlog? The original issue has got over 300 likes and was opened when vscode 1.4.0 was released - there's been 46 feature updates since. What other community support would be necessary for this to at least be looked at?

@pmattei
Copy link

pmattei commented Nov 10, 2020

Can't wait to see it :)

@AlexandreDecan
Copy link

Thank you!

@gjsjohnmurray
Copy link
Contributor

@alexdima should this be working in Insiders now? I selected two files in Explorer, chose "Compare Selected", then tried to toggle word wrap from the View menu. It gave me an info notification"Cannot toggle word wrap in a diff editor."

Version: 1.52.0-insider (user setup)
Commit: 050a123
Date: 2020-11-12T05:43:04.852Z
Electron: 9.3.3
Chrome: 83.0.4103.122
Node.js: 12.14.1
V8: 8.3.110.13-electron.0
OS: Windows_NT x64 10.0.18363

@alexdima
Copy link
Member

@gjsjohnmurray Yes, I've also seen that the toggle action in the View menu does not work yet. Setting word wrap via settings works for now. Let's track in #110468

@h-h-h-h
Copy link
Contributor

h-h-h-h commented Dec 17, 2020

It's finally working! 😲 🤩

@github-actions github-actions bot locked and limited conversation to collaborators Dec 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
diff-editor Diff editor mode issues editor-wrapping Editor line wrapping issues feature-request Request for new features or functionality insiders-released Patch has been released in VS Code Insiders on-testplan
Projects
None yet
Development

Successfully merging a pull request may close this issue.