Sublime Forum

Andy Edits

#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

#21

Currently, “icon_current” is just for the modifying line.
Is it possible to make the “icon_current” for the changes that is not saved (and the “icon_scope” is for saved changes)?

0 Likes

#22

[quote=“singw”]Currently, “icon_current” is just for the modifying line.
Is it possible to make the “icon_current” for the changes that is not saved (and the “icon_scope” is for saved changes)?[/quote]

Hello. Are you referring to saving of the file? That is, you would like two sets of colour - one colour for saved changes?

If so, it would be possible - although I would prefer to use three colours (scopes). I would still want the current edit-region to be differently-coloured, as it is *central *to the whole algorithm.

I’ll await your clarification. Andy.

0 Likes

#23

[quote=“agibsonsw”]

[quote=“singw”]Currently, “icon_current” is just for the modifying line.
Is it possible to make the “icon_current” for the changes that is not saved (and the “icon_scope” is for saved changes)?[/quote]

Hello. Are you referring to saving of the file? That is, you would like two sets of colour - one colour for saved changes?

If so, it would be possible - although I would prefer to use three colours (scopes). I would still want the current edit-region to be differently-coloured, as it is *central *to the whole algorithm.

I’ll await your clarification. Andy.[/quote]

Yes I am referring saving of the file. 1 color for saved changes, 1 color for edited but not saved changes.
For more clear, please have a look on my previous post on other thread https://forum.sublimetext.com/t/highlighting-lines-changed-from-the-last-commit/5867/1#p31999 . After looking the attached screenshot inside that post, you may more clear on what I mean.

Currently the “icon_current” setting is for the last edited line, and “icon_scope” is for changed line (no matter saved or not).

For what you said “three colours”, you mean 1 color for saved lines, 1 color for edited but not saved lines, and 1 color for last edited lines? That’s also great. :smile:
But the last edited lines also got the state of (saved) or (edited but not saved), so, it should be 4 colors. But seems like to much…right? :open_mouth:
So, I hope the 2 colors set and 3 colors set can be an option. :smiley:

0 Likes

#24

@singw
Mmm this is quite a detour from the original purpose of my plug-in; heading towards a Diff-tool or versioning system.

It would require maintaining two sets of regions, being able to combine them when needed, but still keep them distinct. It would also mean that every time a line is edited, the two regions are erased and recreated from scratch (this is how ST-regions work).

I shall think about this some more but, for the moment, I’ll leave the plug-in as it is and concentrate on fixing any niggles, minor changes, etc… Soz, Andy.

0 Likes

#25

[quote=“agibsonsw”]@singw
Mmm this is quite a detour from the original purpose of my plug-in; heading towards a Diff-tool or versioning system.

It would require maintaining two sets of regions, being able to combine them when needed, but still keep them distinct. It would also mean that every time a line is edited, the two regions are erased and recreated from scratch (this is how ST-regions work).

I shall think about this some more but, for the moment, I’ll leave the plug-in as it is and concentrate on fixing any niggles, minor changes, etc… Soz, Andy.[/quote]

Why my idea is heading towards a Diff-tool or versioning system?
The icons (edited, edited but not saved) will be cleared after the file is being closed, no need to save the changed icons’ position, so nothing extra is being saved . When open that file again, those icons of the previous changes will not be show again. Just like the current behavior of this plugin.

“It would also mean that every time a line is edited, the two regions are erased and recreated from scratch”
I don’t quite understand what it means. Isn’t the plugin change the icon when the edit position change now?

0 Likes

#26

When a new edit-line is created, and we move away from this line, then the line is added to the existing edit-regions. However, it is not possible simply to *add *this new region. What happens is:

The existing edit regions are retrieved into a new list using get_regions();
The new edited region is added to this new (temporary) list using append();
This list is iterated (in sorted order) to collapse any adjoining or overlapping regions;
The existing edit-regions are deleted (using erase_regions()) and re-created (from scratch!) using add_regions().

To maintain two distinct (saved and not-yet-saved regions) would require (after a line is edited):

Grab both sets of regions (and the new region);
Merge these to a new list in sorted order;
Iterate this list, merging any that are adjoining or overlap, but *only *if they belong to the same set - saved or not-yet saved;
Split this list into two so that the region-sets saved and not-yet-saved can be reinstated.

A similar process would be necessary in order to produce the jump-lists. That is, to create jump-lists that appear in file-order, but still distinguish between saved and non-saved regions.

Another slight complication is to decide how to handle saved regions that overlap with non-saved regions.

Multiple-undo/redo behaves quite well currently - it took a bit of effort to control this behaviour :wink:. Their behaviour would need to be re-examined when there are two types of regions to maintain, and it may not be possible to control their behaviour to an acceptable level.

Ideas occurred to me to either collapse saved-regions to a single edit point, or to insert hidden content :blush:, but I doubt that either of these options are workable.

So I’m afraid I’m going to leave “as is” for the moment and concentrate on resolving any issues that arise/handling minor change requests. Of course, anyone is welcome to clone/fork my code and work on your suggestion :smile:.

Hope you’re not too disappointed; Andy.

0 Likes

#27

I just rustled up the following code that, when pressing Save, produces a summary of the saved edits:


I wonder if this is of interest?

[code] def on_pre_save(self, view):
_ = adjustEdits(view)
saved_edits = view.get_regions(“edited_rgns”)

    newview = sublime.active_window().new_file()
    edit = newview.begin_edit()
    for i, r in enumerate(sorted(saved_edits)):
        editline, _ = view.rowcol(r.begin())
        newview.insert(edit, newview.size(), "\n-----\nLine: " + str(editline) + '\n')
        newview.insert(edit, newview.size(), view.substr(r))
    newview.end_edit(edit)[/code]
0 Likes

#28


0 Likes