Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
7d60a888
Unverified
Commit
7d60a888
authored
Jun 24, 2020
by
Rémi Verschelde
Committed by
GitHub
Jun 24, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #39783 from neikeq/messaging-codecompletion-localize-fix
C#: Fix completion request with case insensitive resource path
parents
05395cb1
d569b447
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
57 additions
and
2 deletions
+57
-2
StringExtensions.cs
...ono/editor/GodotTools/GodotTools.Core/StringExtensions.cs
+2
-1
MessagingServer.cs
...mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs
+7
-1
FsPathUtils.cs
...es/mono/editor/GodotTools/GodotTools/Utils/FsPathUtils.cs
+48
-0
No files found.
modules/mono/editor/GodotTools/GodotTools.Core/StringExtensions.cs
View file @
7d60a888
...
...
@@ -25,8 +25,9 @@ namespace GodotTools.Core
bool
rooted
=
path
.
IsAbsolutePath
();
path
=
path
.
Replace
(
'\\'
,
'/'
);
path
=
path
[
path
.
Length
-
1
]
==
'/'
?
path
.
Substring
(
0
,
path
.
Length
-
1
)
:
path
;
string
[]
parts
=
path
.
Split
(
new
[]
{
'/'
},
StringSplitOptions
.
RemoveEmptyEntries
);
string
[]
parts
=
path
.
Split
(
new
[]
{
'/'
},
StringSplitOptions
.
RemoveEmptyEntries
);
path
=
string
.
Join
(
Path
.
DirectorySeparatorChar
.
ToString
(),
parts
).
Trim
();
...
...
modules/mono/editor/GodotTools/GodotTools/Ides/MessagingServer.cs
View file @
7d60a888
...
...
@@ -12,6 +12,7 @@ using GodotTools.IdeMessaging;
using
GodotTools.IdeMessaging.Requests
;
using
GodotTools.IdeMessaging.Utils
;
using
GodotTools.Internals
;
using
GodotTools.Utils
;
using
Newtonsoft.Json
;
using
Directory
=
System
.
IO
.
Directory
;
using
File
=
System
.
IO
.
File
;
...
...
@@ -362,8 +363,13 @@ namespace GodotTools.Ides
private
static
async
Task
<
Response
>
HandleCodeCompletionRequest
(
CodeCompletionRequest
request
)
{
// This is needed if the "resource path" part of the path is case insensitive.
// However, it doesn't fix resource loading if the rest of the path is also case insensitive.
string
scriptFileLocalized
=
FsPathUtils
.
LocalizePathWithCaseChecked
(
request
.
ScriptFile
);
var
response
=
new
CodeCompletionResponse
{
Kind
=
request
.
Kind
,
ScriptFile
=
request
.
ScriptFile
};
response
.
Suggestions
=
await
Task
.
Run
(()
=>
Internal
.
CodeCompletionRequest
(
response
.
Kind
,
response
.
ScriptFile
));
response
.
Suggestions
=
await
Task
.
Run
(()
=>
Internal
.
CodeCompletionRequest
(
response
.
Kind
,
scriptFileLocalized
??
request
.
ScriptFile
));
return
response
;
}
}
...
...
modules/mono/editor/GodotTools/GodotTools/Utils/FsPathUtils.cs
0 → 100644
View file @
7d60a888
using
System
;
using
System.IO
;
using
Godot
;
using
GodotTools.Core
;
using
JetBrains.Annotations
;
namespace
GodotTools.Utils
{
public
static
class
FsPathUtils
{
private
static
readonly
string
ResourcePath
=
ProjectSettings
.
GlobalizePath
(
"res://"
);
private
static
bool
PathStartsWithAlreadyNorm
(
this
string
childPath
,
string
parentPath
)
{
// This won't work for Linux/macOS case insensitive file systems, but it's enough for our current problems
bool
caseSensitive
=
!
OS
.
IsWindows
;
string
parentPathNorm
=
parentPath
.
NormalizePath
()
+
Path
.
DirectorySeparatorChar
;
string
childPathNorm
=
childPath
.
NormalizePath
()
+
Path
.
DirectorySeparatorChar
;
return
childPathNorm
.
StartsWith
(
parentPathNorm
,
caseSensitive
?
StringComparison
.
Ordinal
:
StringComparison
.
OrdinalIgnoreCase
);
}
public
static
bool
PathStartsWith
(
this
string
childPath
,
string
parentPath
)
{
string
childPathNorm
=
childPath
.
NormalizePath
()
+
Path
.
DirectorySeparatorChar
;
string
parentPathNorm
=
parentPath
.
NormalizePath
()
+
Path
.
DirectorySeparatorChar
;
return
childPathNorm
.
PathStartsWithAlreadyNorm
(
parentPathNorm
);
}
[
CanBeNull
]
public
static
string
LocalizePathWithCaseChecked
(
string
path
)
{
string
pathNorm
=
path
.
NormalizePath
()
+
Path
.
DirectorySeparatorChar
;
string
resourcePathNorm
=
ResourcePath
.
NormalizePath
()
+
Path
.
DirectorySeparatorChar
;
if
(!
pathNorm
.
PathStartsWithAlreadyNorm
(
resourcePathNorm
))
return
null
;
string
result
=
"res://"
+
pathNorm
.
Substring
(
resourcePathNorm
.
Length
);
// Remove the last separator we added
return
result
.
Substring
(
0
,
result
.
Length
-
1
);
}
}
}
Write
Preview
Markdown
is supported
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