Skip to content

Commit 73c5bf0

Browse files
stevehoovermarijnh
authored andcommitted
[verilog mode] Fixed inadvertent removal of TL-Verilog indent(..) function.
1 parent e6ec325 commit 73c5bf0

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

mode/verilog/verilog.js

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
494494
}
495495

496496
// Compute indentation state:
497-
// o Required indentation on next line
497+
// o Auto indentation on next line
498498
// o Indentation scope styles
499499
var indented = state.indented;
500500
var depth = indented / tlvIndentUnit;
@@ -508,9 +508,12 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
508508
var ch = bodyString[0];
509509
if (tlvScopePrefixChars[ch] && ((match = bodyString.match(tlvIdentMatch)) &&
510510
tlvIdentifierStyle[match[1]])) {
511-
// this line begins scope (except non-region keyword identifiers, which are statements themselves)
511+
// This line begins scope.
512+
// Next line gets indented one level.
513+
indented += tlvIndentUnit;
514+
// Style the next level of indentation (except non-region keyword identifiers,
515+
// which are statements themselves)
512516
if (!(ch == "\\" && chPos > 0)) {
513-
indented += tlvIndentUnit;
514517
state.tlvIndentationStyle[depth] = tlvScopePrefixChars[ch];
515518
if (tlvTrackStatements) {state.statementComment = false;}
516519
depth++;
@@ -524,6 +527,8 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
524527
}
525528
}
526529
}
530+
// Set next level of indentation.
531+
state.tlvNextIndent = indented;
527532
}
528533

529534
if (state.tlvCodeActive) {
@@ -651,9 +656,14 @@ CodeMirror.defineMode("verilog", function(config, parserConfig) {
651656
return style;
652657
},
653658

659+
indent: function(state) {
660+
return (state.tlvCodeActive == true) ? state.tlvNextIndent : -1;
661+
},
662+
654663
startState: function(state) {
655664
state.tlvIndentationStyle = []; // Styles to use for each level of indentation.
656665
state.tlvCodeActive = true; // True when we're in a TLV region (and at beginning of file).
666+
state.tlvNextIndent = -1; // The number of spaces to autoindent the next line if tlvCodeActive.
657667
state.tlvInBlockComment = false; // True inside /**/ comment.
658668
if (tlvTrackStatements) {
659669
state.statementComment = false; // True inside a statement's header comment.

0 commit comments

Comments
 (0)