Sublime Forum

Andy Edits

#1

Currently available via GitHub. I encourage feedback :smile:

[quote]Jump between edited regions - optional gutter icon

Can jump to next or previous edited-lines or use a quick-panel which shows the edited text and line number. (If the edited text is just whitespace then the panel will display the full line’s text.)

A shortcut can toggle outlining of the edited lines. An optional icon can appear in the gutter - although this may interfere if you also use Bookmarks. You could use your own icon if you prefer! icon_scope determines the colour of the icon and outlining: “class” works well for me.

You can remove the edit history for a region using another shortcut, via a quick panel (although you cannot remove the most recent edit). If you highlight some text you can create/add it as an edit-region.

You can list, and jump to, edits across all open files.

Details for edited lines will persist if you close ST, but not if you close the file/view. This is the default persistence behaviour for ST.

My suggestions for your Key Bindings (User) are:
{ “keys”: “ctrl+alt+d”], “command”: “delete_edit” },
{ “keys”: “ctrl+alt+h”], “command”: “toggle_edits” },
{ “keys”: “ctrl+alt+j”], “command”: “quick_edits” },
{ “keys”: “ctrl+alt+k”], “command”: “prev_edit_line” },
{ “keys”: “ctrl+alt+l”], “command”: “next_edit_line” },
{ “keys”: “ctrl+alt+m”], “command”: “list_all_edits” },
{ “keys”: “ctrl+alt+c”], “command”: “create_edit” }

CURRENT LIMITATIONS: Pressing Undo repeatedly may leave an area as an edit-region, even though you have undone all edits to this region. Being able to create and remove edit regions can help with this issue.

Multi-select will only remember the first selection area.[/quote]


0 Likes

#2

A context-menu should make this easier to use :sunglasses:.


0 Likes

#3

Mmm it creates spurious edits towards the top of the page. Teething problems! I’ll shall investigate (got an idea what’s wrong…).

Added: I may have corrected this but I’ll have to keep an eye on it and try to notice when it happens.

0 Likes

#4

With apologies :blush: , but better hold off on this for a while! It’s carrying edit information across the views.

**self **for on_modified and on_selection_modified is a single instance - I was under the impression that these were per view. Shouldn’t be too tricky to fix though.

Soz again, Andy (I was too keen!).

0 Likes

#5

I believe the previous issue is now fixed.

It would be great if someone might give this a trial and offer some feedback :smile:

0 Likes

#6

This is working quite well for me now :smile: .

It doesn’t include automatically inserted tabs, matched brackets or quotes within the current edit region. Therefore, the edit-region may be split into several edits, and/or the region may end before it should. What I’m doing is pressing Ctrl-Alt-H (or using my shortcut menu) to toggle highlighting of the edits. Regardless of this highlighting step, I can select the whole area and use Ctrl-Alt-C to define it as a single edit-region. I can do this at any time and it has the advantage that I can explicitly define the start and end points of the edit region.

It would be possible to create code to handle these automatic insertions (and other factors) but it would be quite detailed and never 100% foolproof. I think it is best with this kind of feature that you/I have some control over how it works. That is, let the feature create the edit regions as you code, then review and correct them to what you decide should be considered as edit regions.

Again, I encourage feedback :wink:.

0 Likes

#7

Will this be put on Package Control’s repository?

0 Likes

#8

Hello. Yes, I have requested this. Andy.

0 Likes

#9

I believe I have resolved any Undo/Redo discrepancies :wink: but I need some feedback to confirm this. Added: Resolved, “to an acceptable degree”!

0 Likes

#10

Sorry about all the updates - I’m almost done :smile:

If there are only spaces and/or tabs between two edit regions then they will be treated as one region. I believe this is reasonable? This will save having to Create areas as a single edit-region manually. Andy.


0 Likes

#11

[quote=“agibsonsw”]

Hello. Yes, I have requested this. Andy.[/quote]

thx. :smiley:

0 Likes

#12

Can the gutter icon just use yellow and green dot?

0 Likes

#13

Do you not like my pencil? :wink:

Just for the moment you could comment out the following two lines in AndyEdits.py and add the third line:

[code]#ICON = path.pardir + ‘/AndyEdits/icon’ if \

sublime.load_settings(PACKAGE_SETTINGS).get(“use_icon”, True) else “”

ICON = “dot”[/code]
[Valid icon names are dot, circle, bookmark and cross.]

Open AndyEdits.sublime-settings and change these two lines:

"icon_scope": "class", "icon_current": "comment"
Change “class” and/or “comment” to different scope names, such as keyword, string, variable, etc. until you get the colours you like. (The colours are determined by your theme, so it requires a little experimenting.) You should probably close and re-open ST each time, after making these changes.

I shall add another setting to make it easier to do this in the future. Andy.

0 Likes

#14

Using a “dot” can now be achieved from the settings alone:

"use_icon" : true, "ST_icon" : "dot"
[On my computer it doesn’t like “circle” for some reason :confused: ]

"use_icon" : true, "ST_icon" : false // will continue to use my pencil.

0 Likes

#15

The latest (and hopefully last!) update handles automatic-insertions better. That is, automatically inserted brackets and quotes will often be included in the edit region.

It achieves this because, if you are starting a new-line or adding content to the end of an existing line, the edit-region will always extend to the end of this line. Automatic insertions will not, however, be accounted for if you begin editing in the middle of an existing line.


Multiple-line snippets are not treated as a single edit region, although the fields that you Tab to and complete will be. Use the Create command if you wish the snippet to be treated as a single edit-region. Andy.

0 Likes

#16

[quote=“agibsonsw”]

Do you not like my pencil? :wink:

Just for the moment you could comment out the following two lines in AndyEdits.py and add the third line:

[code]#ICON = path.pardir + ‘/AndyEdits/icon’ if \

sublime.load_settings(PACKAGE_SETTINGS).get(“use_icon”, True) else “”

ICON = “dot”[/code]
[Valid icon names are dot, circle, bookmark and cross.]

Open AndyEdits.sublime-settings and change these two lines:

"icon_scope": "class", "icon_current": "comment"
Change “class” and/or “comment” to different scope names, such as keyword, string, variable, etc. until you get the colours you like. (The colours are determined by your theme, so it requires a little experimenting.) You should probably close and re-open ST each time, after making these changes.

I shall add another setting to make it easier to do this in the future. Andy.[/quote]

The pencil is too distractive for me. Thank you very much!

0 Likes

#17

I’ve removed my request to place this on **PackageControl **pro-tem. I don’t think there is anything wrong with my code; I’m having rendering issues in ST which I think are related to my running an incorrect Ruby build-file. But until I’m certain I shouldn’t add it to PackageControl.

It would help if anyone using this could report any issues, or confirm that it is working fine? Andy.

0 Likes

#18

Apparently this issue has been encountered before when using add_regions(), and remains an unsolved issue with the ST-API - related to colour-themes.

It can be *fixed *though (apparently) by changing your theme to another (standard) theme, closing and re-starting ST. (If you are already using a standard theme then the issue may not arise.) I presume I can switch back to my custom theme once I’ve restarted ST.

At least it’s nothing to do with my code :smile:. I shall continue to keep an eye on this behaviour. Andy.

0 Likes

#19

would be nice if you could add these to command list (just tooo many key combo to remember :B)

0 Likes

#20

It is available via **PackageControl **now and includes context-menu (right-click) entries.

Just a reminder that in **Windows **there may be a rendering issue (with the scrollbar and ruler). This is due to ST behaviour :blush: , not my code :sunglasses: !

0 Likes