How to let IntelliJ IDEA's Local History ignore Plugins' temporary change and restore to document? - intellij-idea

I am writing a IntelliJ IDEA plugin at here like AceJump, which is used for fast move caret in IDE.
like following, by apply TextAttributes to all 'i' occurrences, and give each 'i' an index char.
after user press 'H', the caret will move to 'i' in the "private".
then change all Markup chars to original 'i'
PROBLEMS
This action will change the Document contents during jump.
so there will be a history change like below. Is there a way to ignore the changes in Local History management?
After press Cmd-z, there is a dialog says "Cannot Undo". how to avoid this?

Instead of changing the document contents, you should paint your navigation markers over the document using, for example, the HintManager class.
If you change the actual document contents, this will have many more consequences besides breaking undo and local history - for example, the document will be reparsed causing false syntax errors to be displayed; any other plugin or IntelliJ IDEA component watching for changes to the document will react to this; the document will be checked out from the VCS if the user is using a VCS such as Perforce that requires an explicit checkout operation; etc. TL/DR: don't do that.

In case someone google and find here. following is my final solution.
I using Swing graphics drawing to show the markers, works great.
please refer for details: https://github.com/whunmr/emacsIDEAs/blob/master/src/org/hunmr/acejump/marker/MarkersPanel.java

Related

Disable reporting erros for path checking in IntelliJ

IntelliJ show the squiggly red underline under require paths (node.js) that it can't find. In my case, I have a file that is copied to a particular place on installation. Their location in the source has nothing to do with their location in the installation. Its especially annoying because intelij shows that red underline for all folders in its file browser.
var x = require('./some/invalid/path')
I like that it has this check, but I want to disable it for this file since it doesn't make sense for that case. How can I do this, ideally in intelliJ 12?
That's how you suppress an inspection for a class, method or statement:
Place your cursor inside the warning statement, press Alt + Enter, choose the entry that describes your warning, and from the sub-menu select Suppress for class or statement.
You will find more info on the IDEA webhelp.
I found a dumb way to do it - make the require path an expression rather than a simple string literal like this:
var x = require('./some/invalid/path'+'')
I guess it confounds intellij enough that it just says "screw it its probably fine".

Disable apostrophe t space Intellij IDEA

When I type in a comment (JavaDoc or line comment) IntelliJ automatically inserts a tag when I type something like // don't and I hit the spacebar after the 't I see // don'< ></> with my cursor ready to type in the first tag. Does anyone know how to disable this behavior? I've tried google searching and searching through the settings with no avail. I'm using IntelliJ IDEA 13.0.1 community edition.
It sounds like a live template is being activated via the sequence tspace, although to the best of my knowledge this is not a default one. Go to File > Settings > [IDE Settings] > Live Templates. Search for a template that has t as its shortcut and inserts tags. Either delete it, or change its activation from space to tab (in the lower right). You may also want to check (and possibly change) the "default expand with" setting at the top.

In Intellij IDEA how do I reload file content's from disk?

In vim I can type :e and reload a file's contents from disk overwriting any changes I've made. It's a nice way to reset in case I've gotten lost or just want to undo all my changes. This obviously doesn't take into account any kind of refactoring, I just want to nuke all changes to buffer. Not even closing and reopening a tab will work.
How do I do this with Intellij IDEA? I'm using Intellij IDEA Ultimate 13 and I've disabled any kind of auto save.
File > Synchronize (Ctrl+Alt+Y)
It will load the file from the file system. If you have unsaved changes, it will ask if you want to discard them.
⌥⌘Y - Synchronize for Mac users
What I do in a similar situation:
Simple - Ctrl+Z, Ctrl+Shift+Z many times to quickly navigate the editing history
VCS rollback - either for the whole file or for the area being edited (by clicking green areas on the left)
Local History. Well, yes, for you case it's granularity is not sufficient, so first might be an option
There is also an option to put a label into Local History if you need to rollback to a specific point in time.
For those who use autosave - it is being triggered when code editor loses focus. So doing Alt-Tab during long editing without compiling or running the code makes sense.
Open the file in another editor, make an insignificant change and save it. PHPStorm will ask you what to do because the file system and in memory copies of the file have diverged. Click "Load File System Changes".
Note, I was unable to use my undo history as it had become corrupt.
Since what I want isn't really possible I wrote an extension to do it for me:
https://github.com/btipling/DiskRead/
I'll add it to the Jetbrains plugin repository, it's called "DiskRead".
I wrote a blog post about how I created this if anyone is curious.

Ignore whitespace changes in IntelliJ changebars

I have a file from our repository where I ran auto-indent (because it was a mess), and now the whole file is marked by blue changebars (down the right hand side of the editor window), making it difficult to find my changes.
I am already ignoring whitespace changes in the diff window (as described here: Intellij and changes tab), is there a way to also do this in the editor window?
I couldn't find a way to completely ignore whitespaces, but IntelliJ (I'm using version 2016) lets you set an option to color whitespace-only changes differentely:
Editor -> General -> Different color for lines with whitespace-only modifications
which helps tremendously.
At the moment [idea 13.5] it seems that is not possible to ignore spaces in the standard editor. You can open a support ticket
We also faced this in the company due the different codestyles used, at the end we settle for:
setting a common codestyle that everyone editing the code should [actually must] follow
reformat the whole codebase to the given codestyle
recommit the formatted code [without any addition or deletion, just the reformat]
It took just a bit of time, but at the end now we are working far better. In this way from that moment onward, we would have all the time the code that would aesthetically the same trough next versions.
You can completely disable the highlight of whitespace modified lines in :
Settings -> Editor -> Color Scheme -> VSC -> Editor Gutter -> Whitespace-modified lines
And then uncheck the background color :
Essentially, you want Intellij to use the --ignore-all-space or --ignore-space-change upon a merge.
My developer team also deals with this challenge because we have different code formatting preferences. The result is every merge is painful for no reason. The team loves being able to have their code formatting, but this negates it.
As of now there is no solution. Intellij has the technology to ignore whitespace, so fixing this is really just adding a check box on the merge diff screen or even in the version control settings.
There is a feature requests IDEA-107714
Please up vote it!
https://youtrack.jetbrains.com/issue/IDEA-107714
Try this,
View --> Active Editor --> Show whitespaces
this is guaranteed to solve your problem

Rename using suggested var name with resharper

I'm Using resharper 6 nighty builds and VB.net. I've a big medium project with multiple files that don't follow the code style conventions of my company.
I've configured resharper with my own convenctions and It suggest to me the right name for each variable (perfect!).
But I can't find any automagic way to make the current name to be replaced with the suggested name.
Are there any way to do it? If not ... did you know ane fearure of coderush Xpress to achieve it?
Thanks.
If you've configured ReSharper with your naming conventions, then it should show a warning (blue squiggly underline) under any identifiers that don't comply. If you put the text cursor on one of those misnamed identifiers, you should see a pyramid icon appear near the left margin. Then you can press Alt+Enter (or click the pyramid icon) to drop down a quick-fix menu. There should be an option in the menu to "Rename to '_myField'". Usually it's the first item in the list, so you can just press Enter again to do the rename.
If you want to do this on everything in a source file, you can use the ReSharper > Inspect > Next Issue in File command (or its keyboard shortcut -- F12 in the IDEA keymap) to move the cursor to the next warning in the file. Then, if it's another name warning, you can use Alt+Enter, Enter again to fix it.
Unfortunately, there isn't a way to automatically fix every instance of a warning at once (though it's been requested; please feel free to vote for RSRP-126551 in their issue tracker).