Skip to content
Permalink
Browse files

Added "reset_diff_markers" setting for resetting the diff markers in …

…the gutter (defaults to true)
  • Loading branch information...
seanliang committed Mar 14, 2019
1 parent cddb6a9 commit 1c6c2acdf8300c4a89b1c78444962599c6153a7a
Showing with 19 additions and 2 deletions.
  1. +7 −0 ConvertToUTF8.py
  2. +3 −0 ConvertToUTF8.sublime-settings
  3. +3 −2 README.md
  4. +1 −0 README.zh_CN.md
  5. +1 −0 messages.json
  6. +4 −0 messages/1.2.13.txt
@@ -31,6 +31,7 @@
REVERTING_FILES = []

CONFIRM_IS_AVAILABLE = ('ok_cancel_dialog' in dir(sublime))
DIFF_IS_AVAILABLE = ('reset_reference_document' in dir(sublime.View))

ENCODINGS_NAME = []
ENCODINGS_CODE = []
@@ -138,6 +139,7 @@ def get_settings():
SETTINGS['lazy_reload'] = settings.get('lazy_reload', True)
SETTINGS['convert_on_find'] = settings.get('convert_on_find', False)
SETTINGS['confidence'] = settings.get('confidence', 0.95)
SETTINGS['reset_diff_markers'] = settings.get('reset_diff_markers', True)

def get_setting(view, key):
# read project specific settings first
@@ -468,6 +470,9 @@ def run(self, edit, encoding=None, stamp=None, detect_on_fail=False):
vp = view.viewport_position()
view.set_viewport_position((0, 0), False)
view.replace(edit, regions, contents)
if DIFF_IS_AVAILABLE and get_setting(view, 'reset_diff_markers'):
view.reset_reference_document()
view.settings().set('origin_content', contents)
sel.clear()
for x in rs:
sel.add(self.find_region(x))
@@ -800,6 +805,8 @@ def undo_me(self, view):
# st3 will reload file immediately
if view.settings().get('revert_to_scratch') or (ST3 and not get_setting(view, 'lazy_reload')):
view.set_scratch(True)
if DIFF_IS_AVAILABLE and get_setting(view, 'reset_diff_markers'):
view.set_reference_document(view.settings().get('origin_content'))

def on_deactivated(self, view):
# st2 will reload file when on_deactivated
@@ -12,6 +12,9 @@
["UTF-8", "UTF-8"]
],

// Reset diff markers after converting
"reset_diff_markers" : true,

// Maximum size for encoding cache, 0 means no cache
"max_cache_size" : 100,

@@ -29,15 +29,16 @@ Configuration
Please check ConvertToUTF8.sublime-settings file for details. You should save your personal settings in a file named "ConvertToUTF8.sublime-settings" under "User" folder. You can set project-specific settings (except encoding_list and max_cache_size) in the .sublime-project file which can be opened via "Project > Edit Project" menu.

* encoding_list: encoding selection list when detection is failed
* reset_diff_markers: reset diff markers after converting (default: true)
* max_cache_size: maximum encoding cache size, 0 means no cache (default: 100)
* max_detect_lines: maximum detection lines, 0 means unlimited (default: 600)
* preview_action: converting the file's content to UTF-8 when previewing it (default: false)
* preview_action: convert the file's content to UTF-8 when previewing it (default: false)
* default_encoding_on_create: specific the default encoding for newly created file (such as "GBK"), empty value means using sublime text's "default_encoding" setting (default: "")
* convert_on_load: convert the file's content to UTF-8 when it is loaded (default: true)
* convert_on_save: convert the file's content from UTF-8 to its original (or specific) encoding when it is saved (default: true)
* convert_on_find: convert the text in Find Results view to UTF-8 (default: false)
* lazy_reload: save file to a temporary location, and reload it in background when switching to other windows or tabs (default: false)
* confidence: The minimum confidence rate which the converting will be performed automatic. (default: 0.95)
* confidence: the minimum confidence rate which the converting will be performed automatic. (default: 0.95)

Usage
------------------
@@ -30,6 +30,7 @@
请查看 ConvertToUTF8.sublime-settings 文件获取详细信息。为防止更新插件时被覆盖,请将个人设置保存到 User 目录中名为 ConvertToUTF8.sublime-settings 文件中。您可以在 .sublime-project 文件(可通过 Project > Edit Project 打开)中指定项目专属设置(除 encoding_list 和 max_cache_size 外)。

* encoding_list:检测失败时显示的编码列表
* reset_diff_markers:在转换后重置差异标记(默认为 true)
* max_cache_size:最大编码缓存数量,0 表示不缓存(默认为 100)
* max_detect_lines:最大检测行数,0 表示不限制(默认为 600)
* preview_action:预览文件时是否将其内容转换为 UTF-8(默认为 false)
@@ -1,4 +1,5 @@
{
"1.2.13": "messages/1.2.13.txt",
"1.2.12": "messages/1.2.12.txt",
"1.2.11": "messages/1.2.11.txt",
"1.2.10": "messages/1.2.10.txt",
@@ -0,0 +1,4 @@
ConvertToUTF8 1.2.13 Changelog

New Features
- Added "reset_diff_markers" setting for resetting the diff markers in the gutter (defaults to true)

0 comments on commit 1c6c2ac

Please sign in to comment.
You can’t perform that action at this time.