1- using System . Numerics ;
2- using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
1+ using OmniSharp . Extensions . LanguageServer . Protocol . Models ;
32using ShaderlabVS ;
4- using static System . Net . Mime . MediaTypeNames ;
53
64namespace ShaderLS
75{
@@ -20,10 +18,27 @@ public Buffer(string text)
2018 SetWordsInDocuments ( text ) ;
2119 }
2220
21+ public string ? GetLine ( Position position )
22+ {
23+ if ( position == null ) return default ;
24+ string [ ] lines = _text . Split ( "\n " ) ;
25+ return lines [ position . Line ] ;
26+ }
27+
28+ public List < string > ? GetLineSplit ( Position position )
29+ {
30+ string ? line = GetLine ( position ) ;
31+ if ( line == null ) return default ;
32+
33+ string front = line . Substring ( 0 , position . Character ) ;
34+ string back = line . Substring ( position . Character , line . Length - position . Character ) ;
35+
36+ return new List < string > { front , back } ;
37+ }
38+
2339 public string GetWordAtPosition ( Position position )
2440 {
25- if ( position == null )
26- return null ;
41+ if ( position == null ) return null ;
2742
2843 string [ ] lines = _text . Split ( "\n " ) ;
2944
@@ -32,7 +47,7 @@ public string GetWordAtPosition(Position position)
3247
3348 string lineStr = lines [ line ] ;
3449
35- string [ ] words = GetWords ( lineStr ) ;
50+ string [ ] words = Helpers . GetWords ( lineStr ) ;
3651
3752 if ( words . Length == 0 )
3853 return null ;
@@ -68,7 +83,7 @@ private void SetWordsInDocuments(string text)
6883 continue ;
6984 }
7085
71- string [ ] words = GetWords ( line ) ;
86+ string [ ] words = Helpers . GetWords ( line ) ;
7287
7388 foreach ( var word in words )
7489 {
@@ -78,13 +93,5 @@ private void SetWordsInDocuments(string text)
7893 line = reader . ReadLine ( ) ;
7994 }
8095 }
81-
82- private string [ ] GetWords ( string text )
83- {
84- return text . Split (
85- new char [ ] { '{' , '}' , ' ' , '\t ' , '(' , ')' , '[' , ']' , '+' , '-' , '*' , '/' , '%' , '^' , '>' , '<' , ':' ,
86- '.' , ';' , '\" ' , '\' ' , '?' , '\\ ' , '&' , '|' , '`' , '$' , '#' , ',' } ,
87- StringSplitOptions . RemoveEmptyEntries ) ;
88- }
8996 }
9097}
0 commit comments