Skip to content

Commit 1fd05a4

Browse files
committed
Use smart typo highlighting in comments
1 parent bbb6dcd commit 1fd05a4

File tree

5 files changed

+7
-1
lines changed

5 files changed

+7
-1
lines changed

v2/editor.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ type Editor struct {
8585
primaryClipboard bool // use the primary or the secondary clipboard on UNIX?
8686
jumpToLetterMode bool // jump directly to a highlighted letter
8787
spellCheckMode bool // spell check mode?
88+
showTypoHighlights bool // show typo highlights in comments?
8889
createDirectoriesIfMissing bool // when saving a file, should directories be created if they are missing?
8990
displayQuickHelp bool // display the quick help box?
9091
noDisplayQuickHelp bool // prevent the quick help box from being displayed?
@@ -153,6 +154,7 @@ func (e *Editor) Copy(withLines bool) *Editor {
153154
e2.primaryClipboard = e.primaryClipboard
154155
e2.jumpToLetterMode = e.jumpToLetterMode
155156
e2.spellCheckMode = e.spellCheckMode
157+
e2.showTypoHighlights = e.showTypoHighlights
156158
e2.createDirectoriesIfMissing = e.createDirectoriesIfMissing
157159
e2.displayQuickHelp = e.displayQuickHelp
158160
e2.blockMode = e.blockMode

v2/highlight.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -809,7 +809,7 @@ func (e *Editor) WriteLines(c *vt.Canvas, fromline, toline LineIndex, cx, cy uin
809809
}
810810

811811
e.applyAccentHighlights(line, runesAndAttributes)
812-
if highlightCurrentLine {
812+
if e.showTypoHighlights {
813813
e.applyTypoHighlights(line, singleLineCommentMarker, runesAndAttributes)
814814
}
815815

v2/insertrune.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ import (
77
// InsertRune will insert a rune at the current data position, with word wrap
88
// Returns true if the line was wrapped
99
func (e *Editor) InsertRune(c *vt.Canvas, r rune) bool {
10+
// Re-enable typo highlights when the user starts typing
11+
e.showTypoHighlights = true
1012
// Insert a regular space instead of a non-breaking space.
1113
// Nobody likes non-breaking spaces.
1214
switch r {

v2/keyloop.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,7 @@ func Loop(tty *vt.TTY, fnord FilenameOrData, lineNumber LineNumber, colNumber Co
13781378
e.blockMode = false
13791379
e.blockCursors = nil
13801380
e.ClearSelection()
1381+
e.showTypoHighlights = false
13811382
c.ShowCursor()
13821383
// If o is used as a man page viewer, or if the escToExit flag is set, exit at the press of esc
13831384
if escToExit || e.mode == mode.ManPage {

v2/neweditor.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ func NewEditor(tty *vt.TTY, c *vt.Canvas, fnord FilenameOrData, lineNumber LineN
109109
cycleFilenames)
110110

111111
e.highlightCurrentText = !envNoColor
112+
e.showTypoHighlights = false
112113

113114
if readOnly || fnord.stdin || monitorAndReadOnly {
114115
e.readOnly = true

0 commit comments

Comments
 (0)