Browse Source

Fixed SD2-569: Wrong file name used for new Link items.

Fixed text editor crash when editing files containing very long words (e.g. 100 KB base64-data in a single line in an XML file).

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/trunk@873 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Daniel Grunwald 20 years ago
parent
commit
dd15782372
  1. 34
      src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs
  2. 2
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/FolderNodeCommands.cs
  3. 2
      src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs

34
src/Libraries/ICSharpCode.TextEditor/Project/Src/Gui/TextView.cs

@ -276,7 +276,7 @@ namespace ICSharpCode.TextEditor @@ -276,7 +276,7 @@ namespace ICSharpCode.TextEditor
return lineNumber == base.textArea.Caret.Line && textArea.MotherTextAreaControl.TextEditorProperties.LineViewerStyle == LineViewerStyle.FullRow;
}
Brush GetBgColorBrush(int lineNumber)
Brush GetBgColorBrush(int lineNumber)
{
if (DrawLineMarkerAtLine(lineNumber)) {
HighlightColor caretLine = textArea.Document.HighlightingStrategy.GetColorFor("CaretMarker");
@ -284,7 +284,7 @@ namespace ICSharpCode.TextEditor @@ -284,7 +284,7 @@ namespace ICSharpCode.TextEditor
}
HighlightBackground background = (HighlightBackground)textArea.Document.HighlightingStrategy.GetColorFor("DefaultBackground");
Color bgColor = background.BackgroundColor;
if (textArea.MotherTextAreaControl.TextEditorProperties.UseCustomLine == true)
if (textArea.MotherTextAreaControl.TextEditorProperties.UseCustomLine == true)
{
bgColor = textArea.Document.CustomLineManager.GetCustomColor(lineNumber, bgColor);
}
@ -581,6 +581,19 @@ namespace ICSharpCode.TextEditor @@ -581,6 +581,19 @@ namespace ICSharpCode.TextEditor
return 0f;
}
if (word.Length > MaximumWordLength) {
float width = 0;
for (int i = 0; i < word.Length; i += MaximumWordLength) {
Point pos = position;
pos.X += (int)width;
if (i + MaximumWordLength < word.Length)
width += DrawDocumentWord(g, word.Substring(i, MaximumWordLength), pos, font, foreColor, backBrush);
else
width += DrawDocumentWord(g, word.Substring(i, word.Length - i), pos, font, foreColor, backBrush);
}
return width;
}
float wordWidth = MeasureStringWidth(g, word, font);
//num = ++num % 3;
@ -616,11 +629,26 @@ namespace ICSharpCode.TextEditor @@ -616,11 +629,26 @@ namespace ICSharpCode.TextEditor
Dictionary<WordFontPair, float> measureCache = new Dictionary<WordFontPair, float>();
// split words after 1000 characters. Fixes GDI+ crash on very longs words, for example
// a 100 KB Base64-file without any line breaks.
const int MaximumWordLength = 1000;
float MeasureStringWidth(Graphics g, string word, Font font)
{
float width;
if (word == null || word.Length == 0)
return 0;
float width;
if (word.Length > MaximumWordLength) {
width = 0;
for (int i = 0; i < word.Length; i += MaximumWordLength) {
if (i + MaximumWordLength < word.Length)
width += MeasureStringWidth(g, word.Substring(i, MaximumWordLength), font);
else
width += MeasureStringWidth(g, word.Substring(i, word.Length - i), font);
}
return width;
}
if (measureCache.TryGetValue(new WordFontPair(word, font), out width)) {
return width;
}

2
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/Commands/FolderNodeCommands.cs

@ -122,7 +122,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands @@ -122,7 +122,7 @@ namespace ICSharpCode.SharpDevelop.Project.Commands
if (res == 1) {
foreach (string fileName in fdiag.FileNames) {
string relFileName = FileUtility.GetRelativePath(node.Project.Directory, fileName);
FileNode fileNode = new FileNode(relFileName, FileNodeStatus.InProject);
FileNode fileNode = new FileNode(fileName, FileNodeStatus.InProject);
FileProjectItem fileProjectItem = new FileProjectItem(node.Project, IncludeFileInProject.GetDefaultItemType(node.Project, fileName));
fileProjectItem.Include = relFileName;
fileProjectItem.Properties.Set("Link", Path.Combine(node.RelativePath, Path.GetFileName(fileName)));

2
src/Main/Base/Project/Src/Gui/Pads/ProjectBrowser/TreeNodes/DirectoryNode.cs

@ -586,7 +586,7 @@ namespace ICSharpCode.SharpDevelop.Project @@ -586,7 +586,7 @@ namespace ICSharpCode.SharpDevelop.Project
}
} else if (node.IsLink) {
string relFileName = FileUtility.GetRelativePath(Project.Directory, node.FileName);
FileNode fileNode = new FileNode(relFileName, FileNodeStatus.InProject);
FileNode fileNode = new FileNode(node.FileName, FileNodeStatus.InProject);
FileProjectItem fileProjectItem = new FileProjectItem(Project, IncludeFileInProject.GetDefaultItemType(Project, node.FileName));
fileProjectItem.Include = relFileName;
fileProjectItem.Properties.Set("Link", Path.Combine(RelativePath, Path.GetFileName(node.FileName)));

Loading…
Cancel
Save