-
Notifications
You must be signed in to change notification settings - Fork 1.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix rename error if using 'LF' eol in windows #748
Conversation
Very useful - is this related to #579? |
@gandhis1 I'm not sure. If you are using Windows and editing python file with |
src/client/refactor/proxy.ts
Outdated
return offset - position.line; | ||
|
||
const winEols = getWindowsLineEndingCount(document.getText(), offset); | ||
return offset - winEols; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@drzunny
You are loading the entire document as a string (document.getText()
), contrary to your comments.
// In order to prevent the one-time loading of large files from taking up too much memory
You might want to use the VS Code api to read text from the document.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, i will update my PR later, thanks for your suggestion
src/client/refactor/proxy.ts
Outdated
return offset - position.line; | ||
|
||
const winEols = getWindowsLineEndingCount(document.getText(), offset); | ||
return offset - winEols; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, if this is specific to windows, shouldn't we check the value of IS_WINDOWS and then invoke the functino getWindowsLineEncodingCount
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it specific to Windows, but in this method (getOffsetAt
), IS_WINDOWS
has already checked before invoke the function getWindowsLineEndingCount
.
@drzunny please could you point me to the rope code that uses LF instead of CRLF |
i check the source code and find the reason in fscommands.py def file_data_to_unicode(data, encoding=None):
result = _decode_data(data, encoding)
if '\r' in result: # <-------------------- here
result = result.replace('\r\n', '\n').replace('\r', '\n')
return result The filepath will be read as a def read(self):
data = self.read_bytes()
try:
return fscommands.file_data_to_unicode(data)
except UnicodeDecodeError as e:
raise exceptions.ModuleDecodeError(self.path, e.reason) it read binary data, and convert to unicode AND REPLACE THE |
Hello, DonJayamanne
I found the
![Bug GIF](https://cloud.githubusercontent.com/assets/1303118/22978485/de341650-f3cd-11e6-9713-62abc9ae1a7c.gif)
rename
feature goes wrong when i edit a py file withLF
eol on Windows(7/8/10).but if I convert the file EOL to
CRLF
, everything is ok.Some editor / IDE will keep both
LF
andCRLF
in one file. So the numbers of character (CR
) are not necessarily equal to the line numbersHere is the effect of this patch:
![This patch](https://cloud.githubusercontent.com/assets/1303118/22979113/28f3f50a-f3d0-11e6-8507-c4cb437abb35.gif)