Skip to content

Commit

Permalink
Fix inaccurate Convert tabs to spaces processing when elastic tabstop…
Browse files Browse the repository at this point in the history
…s are used with DirectWrite. Update changelog and version info.
  • Loading branch information
Coises committed Feb 29, 2024
1 parent d2fc8b1 commit 39e20ae
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Columns++ for Notepad++ -- Releases

## Version 1.0.5 -- February 29th, 2024

* Correction to support for the new notification planned in Notepad++ 8.6.5.
* Fix inaccurate Convert tabs to spaces processing when elastic tabstops are used with DirectWrite enabled.

## Version 1.0.4 -- February 23rd, 2024

* Support planned changes to notifications in Notepad++ versions greater than 8.6.4. (Columns++ has problems with Notepad++ versions 8.6.3 and 8.6.4; it is recommended to skip these versions if you use Columns++.)
Expand Down
Binary file modified src/ColumnsPlusPlus.rc
Binary file not shown.
11 changes: 5 additions & 6 deletions src/Convert.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -517,18 +517,17 @@ void ColumnsPlusPlusData::tabsToSpaces() {
if (sci.SelectionEmpty()) selections.emplace_back(0, sci.Length());
else {
int n = sci.Selections();
for (int i = 0; i < n; ++i)
selections.emplace_back(sci.SelectionNStart(i), sci.SelectionNEnd(i));
for (int i = 0; i < n; ++i) selections.emplace_back(sci.SelectionNStart(i), sci.SelectionNEnd(i));
std::sort(selections.begin(), selections.end(),
[](const std::pair<Scintilla::Position, Scintilla::Position>& x,
const std::pair<Scintilla::Position, Scintilla::Position>& y) {return x.first > y.first; });
const std::pair<Scintilla::Position, Scintilla::Position>& y) {return x.first > y.first; });
}

Scintilla::Line firstSelectedLine = sci.LineFromPosition(selections[selections.size() - 1].first);
Scintilla::Line lastSelectedLine = sci.LineFromPosition(selections[0].second);
Scintilla::Line lastSelectedLine = sci.LineFromPosition(selections[0].second);
setTabstops(dd, firstSelectedLine, lastSelectedLine);

int blankWidth = sci.TextWidth(STYLE_DEFAULT, " ");
const int blank1440 = sci.TextWidth(STYLE_DEFAULT, std::string(1440, ' ').data());
sci.SetSearchFlags(Scintilla::FindOption::MatchCase);
sci.BeginUndoAction();

Expand All @@ -544,7 +543,7 @@ void ColumnsPlusPlusData::tabsToSpaces() {
}
repl += text.substr(i, j - i);
int width = sci.PointXFromPosition(sel.first + j + 1) - sci.PointXFromPosition(sel.first + j);
int count = (2 * width + blankWidth) / (2 * blankWidth);
int count = (width * 2880 + blank1440) / (2 * blank1440);
repl += std::string(count, ' ');
i = j + 1;
}
Expand Down

0 comments on commit 39e20ae

Please sign in to comment.