You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: src/language/providers/attributeCompletion.ts
+150-7Lines changed: 150 additions & 7 deletions
Original file line number
Diff line number
Diff line change
@@ -16,7 +16,7 @@
16
16
*/
17
17
18
18
import*asvscodefrom'vscode'
19
-
19
+
import{xml2js}from'xml-js'
20
20
import{
21
21
XmlItem,
22
22
getSchemaNsPrefix,
@@ -67,6 +67,144 @@ function getCompletionItems(
67
67
returncompItems
68
68
}
69
69
70
+
/** Retrieves relevant lines of the document for use in prunedDuplicateAttributes
71
+
* Format of return is as follows [relevant parts of the string, index representing the location of the cursor in the string]
72
+
*
73
+
* @param position
74
+
* @param document
75
+
* @returns
76
+
*/
77
+
functiongetPotentialAttributeText(
78
+
position: vscode.Position,
79
+
document: vscode.TextDocument
80
+
): [string,number]{
81
+
// Overall strategy: Find the lines that are relevant to the XML element we're looking at. The element can be incomplete and not closed.
82
+
letlowerLineBound: number=position.line
83
+
letupperLineBound: number=position.line
84
+
85
+
// Determining the lowerbound strategy: Traverse backwards line-by-line until we encounter an opening character (<)
86
+
while(
87
+
lowerLineBound>0&&// Make sure we aren't going to negative line indexes
88
+
document.lineAt(lowerLineBound).text.indexOf('<')==-1// continue going up the document if there is no <
89
+
){
90
+
lowerLineBound--// traverse backwards via decrementing line index
91
+
}
92
+
93
+
// Upperbound strategy: Increment the upperLineBound 1 line downward to avoid the edge case it's equal to the lowerLineBound and there's more content beyond lowerLineBound
94
+
if(upperLineBound!=document.lineCount-1){
95
+
upperLineBound++
96
+
}
97
+
98
+
// then, check the subsequent lines if there is an opening character (<)
0 commit comments