Indent tabs by 4 spaces in code block editor dialog
This commit is contained in:
parent
b06f213522
commit
3d0f4a7787
2 changed files with 13 additions and 0 deletions
|
|
@ -4,6 +4,7 @@
|
|||
* Add 'Created at' to time log table.
|
||||
* Show total hours for the day in the time log table (not just in the widget in sidebar)
|
||||
* Pomodoro timer is now in the sidebar when toggled on, rather than as a separate dialog, so it stays out of the way
|
||||
* Indent tabs by 4 spaces in code block editor dialog
|
||||
|
||||
# 0.6.1
|
||||
|
||||
|
|
|
|||
|
|
@ -40,9 +40,21 @@ class CodeEditorWithLineNumbers(QPlainTextEdit):
|
|||
self.cursorPositionChanged.connect(self._line_number_area.update)
|
||||
|
||||
self._update_line_number_area_width()
|
||||
self._update_tab_stop_width()
|
||||
|
||||
# ---- layout / sizing -------------------------------------------------
|
||||
|
||||
def setFont(self, font: QFont) -> None: # type: ignore[override]
|
||||
"""Ensure tab width stays at 4 spaces when the font changes."""
|
||||
super().setFont(font)
|
||||
self._update_tab_stop_width()
|
||||
|
||||
def _update_tab_stop_width(self) -> None:
|
||||
"""Set tab width to 4 spaces."""
|
||||
metrics = QFontMetrics(self.font())
|
||||
# Tab width = width of 4 space characters
|
||||
self.setTabStopDistance(metrics.horizontalAdvance(" ") * 4)
|
||||
|
||||
def line_number_area_width(self) -> int:
|
||||
# Enough digits for large-ish code blocks.
|
||||
digits = max(2, len(str(max(1, self.blockCount()))))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue