Sublime Forum

Andy Edits

#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

#29

Iā€™ve added this to my repo in case anyone wants to explore it as an option.

Just add a setting ā€œoutput_editsā€: true and every time you Save it will produce a summary view, which can be saved or abandoned.

Edited: It is ā€œoutput_editsā€ (not ā€œoutput_optionsā€).

0 Likes

#30

@singw Perhaps Iā€™m over-thinking this. Iā€™ve updated it to read the following settings:

"saved_scope": "keyword", // whether to outline saved edit-regions "saved_edits": true, // whether to create a summary of edits on save "output_edits": false

If ā€˜saved_editsā€™ is true then pressing save will outline the edited-regions with the scope given by ā€˜saved_scopeā€™ (defaults to keyword). Let me know how you get on with this.

ā€˜output_editsā€™ determines whether to produce the output summary on save, as mentioned in my previous post. Andy.

0 Likes

#31

[quote=ā€œagibsonswā€]@singw Perhaps Iā€™m over-thinking this. Iā€™ve updated it to read the following settings:

"saved_scope": "keyword", // whether to outline saved edit-regions "saved_edits": true, // whether to create a summary of edits on save "output_edits": false

If ā€˜saved_editsā€™ is true then pressing save will outline the edited-regions with the scope given by ā€˜saved_scopeā€™ (defaults to keyword). Let me know how you get on with this.

ā€˜output_editsā€™ determines whether to produce the output summary on save, as mentioned in my previous post. Andy.[/quote]

Thanks for your work! :smiley:
But outlining the edited regions is quite distracting for me, I prefer just an icon on the gutter.

And after I used the above settings, no icons any more on changes, but only those outline.

0 Likes

#32

Yes, it is distracting. Also, editing within a ā€˜savedā€™ region, it still shows as a saved region.

Iā€™ll probably remove this feature, and the edits-summary, tomorrow (although they donā€™t do anything unless we add their settings).

Andy.

0 Likes