Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Utilities
Kate
Commits
dec54c31
Commit
dec54c31
authored
Mar 06, 2014
by
Kåre Särs
Browse files
XML indentation: fix indentation when thee are empty lines
BUG: 330089
BUG: 331764
parent
a052db14
Changes
4
Hide whitespace changes
Inline
Side-by-side
part/script/data/indentation/xml.js
View file @
dec54c31
...
...
@@ -134,23 +134,32 @@ function calcSteps(code) {
// -1: keep last indent
// -2: do nothing
function
indent
(
lineNr
,
indentWidth
,
char
)
{
dbg
(
"
lineNr:
"
+
lineNr
);
dbg
(
"
char:
"
+
char
);
dbg
(
"
lineNr:
"
+
lineNr
+
"
indentWidth:
"
+
indentWidth
+
"
char:
"
+
char
);
if
(
lineNr
==
0
)
// don't ever act on document's first line
return
-
2
;
var
lastLineNr
=
lineNr
-
1
;
var
lastLine
=
getCode
(
lastLineNr
);
dbg
(
"
lastLine1:
"
+
lastLine
);
while
(
lastLine
==
""
)
{
lastLineNr
--
;
if
(
lastLineNr
<=
0
)
{
return
-
1
;
}
lastLine
=
getCode
(
lastLineNr
);
}
dbg
(
"
lastLine2:
"
+
lastLine
);
// default action (for char == '\n' or char == '')
var
indent
=
_calcAttributeIndent
(
lineNr
-
1
,
indentWidth
);
var
indent
=
_calcAttributeIndent
(
l
astL
ineNr
,
indentWidth
);
if
(
indent
!=
-
1
)
{
return
indent
;
}
dbg
(
"
indent:
"
+
indent
);
indent
=
Math
.
max
(
document
.
firstVirtualColumn
(
lastLineNr
),
0
);
dbg
(
"
indent:
"
+
indent
);
indent
=
Math
.
max
(
document
.
firstVirtualColumn
(
lineNr
-
1
),
0
);
var
lastLine
=
getCode
(
lineNr
-
1
);
dbg
(
"
lastLine:
"
+
lastLine
);
if
(
lastLine
==
""
)
{
return
-
1
;
}
var
steps
=
calcSteps
(
lastLine
);
// unindenting separate closing tags are dealt with by last line
...
...
tests/data/indent/xml/empty_lines/expected
0 → 100644
View file @
dec54c31
<ul>
<li>a</li>
<li>b</li>
<!--li>c</li-->
</ul>
<ul>
<li>a</li>
<li>b</li>
</ul>
tests/data/indent/xml/empty_lines/input.js
0 → 100644
View file @
dec54c31
v
.
setCursorPosition
(
0
,
0
);
v
.
selectAll
();
var
r
=
v
.
selection
();
if
(
r
.
isValid
()
)
{
d
.
align
(
r
);
}
tests/data/indent/xml/empty_lines/origin
0 → 100644
View file @
dec54c31
<ul>
<li>a</li>
<li>b</li>
<!--li>c</li-->
</ul>
<ul>
<li>a</li>
<li>b</li>
</ul>
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment