File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change @@ -172,11 +172,7 @@ impl LanguageServer for DjangoLanguageServer {
172172 name : SERVER_NAME . to_string ( ) ,
173173 version : Some ( SERVER_VERSION . to_string ( ) ) ,
174174 } ) ,
175- offset_encoding : Some ( match encoding {
176- djls_workspace:: PositionEncoding :: Utf8 => "utf-8" . to_string ( ) ,
177- djls_workspace:: PositionEncoding :: Utf16 => "utf-16" . to_string ( ) ,
178- djls_workspace:: PositionEncoding :: Utf32 => "utf-32" . to_string ( ) ,
179- } ) ,
175+ offset_encoding : Some ( encoding. to_string ( ) ) ,
180176 } )
181177 }
182178
Original file line number Diff line number Diff line change 1+ use std:: fmt;
2+
13/// Protocol-specific text position handling.
24///
35/// This module provides types and functions for converting between different
@@ -38,6 +40,16 @@ pub enum PositionEncoding {
3840 Utf32 ,
3941}
4042
43+ impl fmt:: Display for PositionEncoding {
44+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
45+ match self {
46+ Self :: Utf8 => write ! ( f, "utf-8" ) ,
47+ Self :: Utf16 => write ! ( f, "utf-16" ) ,
48+ Self :: Utf32 => write ! ( f, "utf-32" ) ,
49+ }
50+ }
51+ }
52+
4153impl LineIndex {
4254 /// Convert a line/column position to a byte offset with encoding awareness.
4355 ///
@@ -162,6 +174,13 @@ mod tests {
162174 assert_eq ! ( offset_utf8, ByteOffset ( 10 ) ) ;
163175 }
164176
177+ #[ test]
178+ fn test_position_encoding_display ( ) {
179+ assert_eq ! ( PositionEncoding :: Utf8 . to_string( ) , "utf-8" ) ;
180+ assert_eq ! ( PositionEncoding :: Utf16 . to_string( ) , "utf-16" ) ;
181+ assert_eq ! ( PositionEncoding :: Utf32 . to_string( ) , "utf-32" ) ;
182+ }
183+
165184 #[ test]
166185 fn test_line_col_to_offset_ascii_fast_path ( ) {
167186 let text = "Hello world" ;
You can’t perform that action at this time.
0 commit comments