Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions LiteDB.Studio/Classes/UIExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ public static void BindBsonData(this DataGridView grd, TaskData data)
grd.Columns.Add(key, key);

col = grd.Columns[key];
col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

col.ReadOnly = key == "_id";
//col.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;
col.Width = 150;
col.ReadOnly = key == "_id";
}
}

Expand All @@ -58,7 +58,9 @@ public static void BindBsonData(this DataGridView grd, TaskData data)
var cell = row.Cells[col.Index];

cell.Style.BackColor = Color.White;
cell.Value = value.IsDocument ? value[key] : value;
var bson = value.IsDocument ? value[key] : value;
cell.Value = bson;
cell.Tag = bson;

row.ReadOnly = key == "_id";
}
Expand Down
5 changes: 5 additions & 0 deletions LiteDB.Studio/Forms/MainForm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -815,6 +815,11 @@ private void GrdResult_CellFormatting(object sender, DataGridViewCellFormattingE
e.Value = JsonSerializer.Serialize(value);
break;
}

if (e.Value is string str && str.Length > 150)
{
e.Value = str.Substring(0, 150) + "...";
}
Comment on lines +819 to +822
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Don’t replace the formatted cell value with a truncated preview.

Line 821 makes the grid display only the first 150 characters, so long JSON/text still cannot be fully viewed in the grid after resizing the column. Since UIExtensions now uses fixed initial widths, keep e.Value intact and let the grid clip visually.

🐛 Proposed fix
-            if (e.Value is string str && str.Length > 150)
-            {
-                e.Value = str.Substring(0, 150) + "...";
-            }
+            // Keep the full formatted value available in the grid; the fixed
+            // column width clips the visual rendering without losing content.
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
if (e.Value is string str && str.Length > 150)
{
e.Value = str.Substring(0, 150) + "...";
}
// Keep the full formatted value available in the grid; the fixed
// column width clips the visual rendering without losing content.
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@LiteDB.Studio/Forms/MainForm.cs` around lines 819 - 822, The CellFormatting
handler in MainForm.cs is replacing e.Value with a truncated string (the if
block that uses str.Substring(0, 150)), which prevents the grid from ever
showing the full cell content even after column resize; remove that truncation
and leave e.Value unchanged (do not assign the shortened string), so the grid
will clip visually per UIExtensions' fixed widths; if a hover preview is desired
later, populate the cell's ToolTipText or similar instead of modifying e.Value.

}

private void LoadLastDbChecked_Changed(object sender, EventArgs e)
Expand Down