From af42cd39ecc098eb4de383a5b603023a1d7927a8 Mon Sep 17 00:00:00 2001 From: Isaac Muse Date: Wed, 16 Jan 2019 22:35:59 -0700 Subject: [PATCH] Fix selection issue (#71) Fixes #66 --- CHANGES.md | 4 ++++ hex_highlighter.py | 8 +++++++- support.py | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index b1b6eb2..113d14f 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,3 +1,7 @@ +# HexViewer 2.6.4 + +- **FIX**: Fix issue with with selecting the correct hex byte when a character in the ASCII column is selected on the last row. + # HexViewer 2.6.3 - **FIX**: Fix change log auto-linking issue. diff --git a/hex_highlighter.py b/hex_highlighter.py index 8b09861..ff0a005 100644 --- a/hex_highlighter.py +++ b/hex_highlighter.py @@ -181,13 +181,19 @@ def ascii_to_hex(self, sel): end = sel.end() num_bytes = 0 ascii_range = view.extract_scope(sel.begin()) + if view.match_selector(ascii_range.begin(), 'keyword.ascii-start.hex'): + ascii_range = sublime.Region(ascii_range.begin() + 1, ascii_range.end()) + if view.substr(ascii_range.end()) == '\x00': + offset = 0 + else: + offset = 1 # Determine if selection is within ascii range if ( start >= ascii_range.begin() and ( # Single selection should ignore the end of line selection - (end == start and end < ascii_range.end() - 1) or + (end == start and end < ascii_range.end() - offset) or (end != start and end < ascii_range.end()) ) ): diff --git a/support.py b/support.py index 3e49487..238c5af 100644 --- a/support.py +++ b/support.py @@ -5,7 +5,7 @@ import webbrowser import re -__version__ = "2.6.3" +__version__ = "2.6.4" __pc_name__ = 'HexViewer' CSS = '''