@@ -10,9 +10,13 @@ export function normalizePathToUri(path: string | undefined = ""): string {
1010 return `/${ normalizedPath } ` ;
1111}
1212
13+ export function isWindows ( ) : boolean {
14+ return process . platform === "win32" ;
15+ }
16+
1317export function uriPathToDiskPath ( path : string ) : string {
1418 // If Windows, convert URI path to disk path
15- if ( process . platform === "win32" ) {
19+ if ( isWindows ( ) ) {
1620 return path . replace ( / ^ \/ / , "" ) ;
1721 }
1822 // For other platforms, return the path as is
@@ -40,6 +44,30 @@ export function formatPath(path: string): string {
4044 return vscode . workspace . asRelativePath ( path ) ;
4145}
4246
47+ const MAX_LINE_LENGTH = 80 ;
48+
49+ export function addNewlinesToLongLines ( text : string ) : string {
50+ if ( ! isWindows ( ) ) {
51+ return text ;
52+ }
53+ const initialLines = text . split ( "\n" ) ;
54+ const lines : string [ ] = [ ] ;
55+ for ( const line of initialLines ) {
56+ let currentLine = line ;
57+
58+ while ( currentLine . length > MAX_LINE_LENGTH ) {
59+ lines . push ( currentLine . substring ( 0 , MAX_LINE_LENGTH ) ) ;
60+ currentLine = currentLine . substring ( MAX_LINE_LENGTH ) ;
61+ }
62+
63+ if ( currentLine . length > 0 ) {
64+ lines . push ( currentLine ) ;
65+ }
66+ }
67+
68+ return lines . join ( "\n" ) ;
69+ }
70+
4371export function oilUriToDiskPath ( uri : vscode . Uri ) : string {
4472 // Convert an Oil URI to a file system path
4573 if ( ! ( uri . scheme === OIL_SCHEME || uri . scheme === OIL_PREVIEW_SCHEME ) ) {
0 commit comments